From d62b85f0158f96d261b47e57078b24bcb8abaf0f Mon Sep 17 00:00:00 2001 From: wahyun Date: Tue, 2 Apr 2024 10:19:20 +0700 Subject: [PATCH] add image url --- src/views/Master/MasterCompany/DialogForm.js | 31 ++++++++++++++------ src/views/Master/MasterCompany/index.js | 3 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/views/Master/MasterCompany/DialogForm.js b/src/views/Master/MasterCompany/DialogForm.js index 1b34c6c..33149f0 100644 --- a/src/views/Master/MasterCompany/DialogForm.js +++ b/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 ? ( Image Preview ) : ('-') ) : ( {imageSlider && imageSlider.map((item, index) => ( - + ))} diff --git a/src/views/Master/MasterCompany/index.js b/src/views/Master/MasterCompany/index.js index 80fe48b..9c5c9b5 100644 --- a/src/views/Master/MasterCompany/index.js +++ b/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); } }