Browse Source

add image url

pull/1/head
wahyun 7 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 moment from 'moment';
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';
const token = window.localStorage.getItem('token');
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 = () => {
return (
<>
@ -823,21 +841,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
typeImage !== 'imageSlider' ? (
imageLogin || imageHeader || imageFavIcon ? (
<img
src={
`${BASE_SIMPRO_LUMEN_IMAGE}/` +
(typeImage === 'imageHeader' && imageHeader ? imageHeader.image :
typeImage === 'imageLogin' && imageLogin ? imageLogin.image :
typeImage === 'favIcon' && imageFavIcon ? imageFavIcon.image : '')
}
src={imageUrl}
style={{ maxWidth: "100%" }}
alt="Image Preview"
alt="Not Image Preview"
/>
) : ('-')
) : (
<Row style={{ display: 'flex', justifyContent: 'center' }}>
{imageSlider && imageSlider.map((item, index) => (
<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>
))}
</Row>

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

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

Loading…
Cancel
Save