Browse Source

add image url

pull/1/head
wahyun 9 months ago
parent
commit
d62b85f015
  1. 31
      src/views/Master/MasterCompany/DialogForm.js
  2. 3
      src/views/Master/MasterCompany/index.js

31
src/views/Master/MasterCompany/DialogForm.js

@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import moment from 'moment'; import moment from 'moment';
import { import {
USER_SEARCH, MENU_COMPANY_DELETE, USER_DELETE, ROLE_SEARCH, COMPANY_MANAGEMENT_GET_ID, MENU_COMPANY_SEARCH, BASE_SIMPRO_LUMEN_IMAGE USER_SEARCH, MENU_COMPANY_DELETE, USER_DELETE, ROLE_SEARCH, COMPANY_MANAGEMENT_GET_ID, MENU_COMPANY_SEARCH, BASE_SIMPRO_LUMEN_IMAGE_COMPANY
} from '../../../const/ApiConst'; } from '../../../const/ApiConst';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const config = { const config = {
@ -594,6 +594,24 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
} }
}; };
const imageUrl = (() => {
let imageType = '';
let createdAt = '';
if (typeImage === 'imageHeader' && imageHeader) {
imageType = imageHeader.image;
createdAt = moment(imageHeader.created_at).format('YYYY-MM');
} else if (typeImage === 'imageLogin' && imageLogin) {
imageType = imageLogin.image;
createdAt = moment(imageLogin.created_at).format('YYYY-MM');
} else if (typeImage === 'favIcon' && imageFavIcon) {
imageType = imageFavIcon.image;
createdAt = moment(imageFavIcon.created_at).format('YYYY-MM');
}
return BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageType, companyNameProp, createdAt);
})();
const renderFromCompany = () => { const renderFromCompany = () => {
return ( return (
<> <>
@ -823,21 +841,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
typeImage !== 'imageSlider' ? ( typeImage !== 'imageSlider' ? (
imageLogin || imageHeader || imageFavIcon ? ( imageLogin || imageHeader || imageFavIcon ? (
<img <img
src={ src={imageUrl}
`${BASE_SIMPRO_LUMEN_IMAGE}/` +
(typeImage === 'imageHeader' && imageHeader ? imageHeader.image :
typeImage === 'imageLogin' && imageLogin ? imageLogin.image :
typeImage === 'favIcon' && imageFavIcon ? imageFavIcon.image : '')
}
style={{ maxWidth: "100%" }} style={{ maxWidth: "100%" }}
alt="Image Preview" alt="Not Image Preview"
/> />
) : ('-') ) : ('-')
) : ( ) : (
<Row style={{ display: 'flex', justifyContent: 'center' }}> <Row style={{ display: 'flex', justifyContent: 'center' }}>
{imageSlider && imageSlider.map((item, index) => ( {imageSlider && imageSlider.map((item, index) => (
<Col md={6} style={{ marginBottom: '20px' }}> <Col md={6} style={{ marginBottom: '20px' }}>
<img key={index} src={`${BASE_SIMPRO_LUMEN_IMAGE}/` + item.image} style={{ width: '150px', display: 'block' }}></img> <img key={index} src={`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(item?.image, companyNameProp, moment(item?.created_at).format('YYYY-MM'))}`} style={{ width: '150px', display: 'block' }}></img>
</Col> </Col>
))} ))}
</Row> </Row>

3
src/views/Master/MasterCompany/index.js

@ -147,7 +147,8 @@ const MasterCompany = ({ params }) => {
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
setProjectImageHeader(result.data.data); const dataRes = result.data.data;
setProjectImageHeader(dataRes);
} }
} }

Loading…
Cancel
Save