|
|
|
@ -12,7 +12,7 @@ import 'antd/dist/antd.css';
|
|
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
|
import axios from "../../../const/interceptorApi" |
|
|
|
|
import { |
|
|
|
|
USER_SEARCH, MENU_COMPANY_DELETE, USER_DELETE, ROLE_SEARCH, COMPANY_MANAGEMENT_GET_ID, MENU_COMPANY_SEARCH |
|
|
|
|
USER_SEARCH, MENU_COMPANY_DELETE, USER_DELETE, ROLE_SEARCH, COMPANY_MANAGEMENT_GET_ID, MENU_COMPANY_SEARCH, BASE_SIMPRO_LUMEN_IMAGE |
|
|
|
|
} from '../../../const/ApiConst'; |
|
|
|
|
const token = window.localStorage.getItem('token'); |
|
|
|
|
const config = { |
|
|
|
@ -22,7 +22,7 @@ const config = {
|
|
|
|
|
"Content-type": `application/json` |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, companyID, companyNameProp, dataEditCompany, imageHeader, imageFavIcon, imageLogin, lastIdCompany }) => { |
|
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, companyID, companyNameProp, dataEditCompany, imageHeader, imageFavIcon, imageLogin, imageSlider, lastIdCompany }) => { |
|
|
|
|
const { Option } = Select |
|
|
|
|
const { t } = useTranslation() |
|
|
|
|
const [registrationnumber, setRegistrationNumber] = useState('') |
|
|
|
@ -33,6 +33,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
const [description, setDescription] = useState('') |
|
|
|
|
const [logoLogin, setLogoLogin] = useState(null) |
|
|
|
|
const [logoHeader, setLogoHeader] = useState(null) |
|
|
|
|
const [sliderLogin, setSliderLogin] = useState(null) |
|
|
|
|
const [favIcon, setFavIcon] = useState(null) |
|
|
|
|
const [loginInstruction, setLoginInstruction] = useState('') |
|
|
|
|
const [about, setAbout] = useState('') |
|
|
|
@ -65,6 +66,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
const [openDialogMenu, setOpenDialogMenu] = useState(false) |
|
|
|
|
const [typeDialogMenu, setTypeDialogMenu] = useState("add") |
|
|
|
|
const [loading, setLoading] = useState(true); |
|
|
|
|
const [modalOpen, setModalOpen] = useState(false); |
|
|
|
|
const [typeImage, setTypeImage] = useState(''); |
|
|
|
|
useEffect(() => { |
|
|
|
|
if (companyID && typeDialog === 'Set') { |
|
|
|
|
setLoading(true) |
|
|
|
@ -98,6 +101,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
} else { |
|
|
|
|
setAvailableBaseUrl(false) |
|
|
|
|
} |
|
|
|
|
setSliderLogin(null) |
|
|
|
|
} else { |
|
|
|
|
setId(0) |
|
|
|
|
setCompanyName('') |
|
|
|
@ -111,6 +115,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
setTemplate('') |
|
|
|
|
setLogoLogin(null) |
|
|
|
|
setLogoHeader(null) |
|
|
|
|
setSliderLogin(null) |
|
|
|
|
setFavIcon(null) |
|
|
|
|
setBaseUrl([]) |
|
|
|
|
} |
|
|
|
@ -391,6 +396,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
data.imageLogin = logoLogin ? logoLogin : null; |
|
|
|
|
data.imageHeader = logoHeader ? logoHeader : null; |
|
|
|
|
data.imageFavicon = favIcon ? favIcon : null; |
|
|
|
|
data.imageSlider = sliderLogin ? sliderLogin : null; |
|
|
|
|
closeDialog('save', data); |
|
|
|
|
setLoading(false); |
|
|
|
|
} else if (typeDialog === "Edit") { |
|
|
|
@ -413,6 +419,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
data.imageLogin = logoLogin ? logoLogin : null; |
|
|
|
|
data.imageHeader = logoHeader ? logoHeader : null; |
|
|
|
|
data.imageFavicon = favIcon ? favIcon : null; |
|
|
|
|
data.imageSlider = sliderLogin ? sliderLogin : null; |
|
|
|
|
closeDialog('edit', data); |
|
|
|
|
setLoading(false); |
|
|
|
|
} |
|
|
|
@ -427,6 +434,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
closeDialog('cancel', 'none') |
|
|
|
|
setDatatable([]); |
|
|
|
|
setBaseUrl([]); |
|
|
|
|
setSliderLogin(null); |
|
|
|
|
setAvailableBaseUrl(false); |
|
|
|
|
setLoading(false); |
|
|
|
|
} |
|
|
|
@ -568,9 +576,27 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const truncateText = (text, maxLength) => { |
|
|
|
|
if (text.length > maxLength) { |
|
|
|
|
return text.substring(0, maxLength) + '...'; |
|
|
|
|
} |
|
|
|
|
return text; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const toggleModal = () => { |
|
|
|
|
setModalOpen(!modalOpen); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleImageClick = async (type) => { |
|
|
|
|
setTypeImage(type); |
|
|
|
|
if (type != '') { |
|
|
|
|
toggleModal(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const renderFromCompany = () => { |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<Form> |
|
|
|
|
<Row> |
|
|
|
|
<Col md={12}> |
|
|
|
@ -654,7 +680,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
<Label className="capitalize">Template Application<span style={{ color: "red" }}>*</span></Label> |
|
|
|
|
<Select style={{ width: "100%" }} defaultValue={template} onChange={(e) => setTemplate(e)} placeholder="Select a template for application"> |
|
|
|
|
<Option value={1}>Construction</Option> |
|
|
|
|
{/* <Option value={2}>IT (Information AND Technology)</Option> */} |
|
|
|
|
</Select> |
|
|
|
|
</FormGroup> |
|
|
|
|
</Col> |
|
|
|
@ -694,7 +719,37 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
accept="image/*" |
|
|
|
|
onChange={(e) => setLogoLogin(e.target.files[0])} |
|
|
|
|
/> |
|
|
|
|
<small>{imageLogin ? imageLogin.image : <p style={{ color: "red" }}>Not found image</p> }</small> |
|
|
|
|
<small onClick={imageLogin ? () => handleImageClick('imageLogin') : ''} style={{ cursor: imageLogin ? "pointer" : ""}}> |
|
|
|
|
<p style={{ textDecoration: imageLogin ? 'underline' : 'none', color: imageLogin ? 'blue' : 'red' }}> |
|
|
|
|
{ |
|
|
|
|
imageLogin ? ( |
|
|
|
|
"View Image" |
|
|
|
|
) : ( |
|
|
|
|
"Not found image" |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</p> |
|
|
|
|
</small> |
|
|
|
|
</FormGroup> |
|
|
|
|
<FormGroup> |
|
|
|
|
<Label className="capitalize" style={{ fontWeight: "bold" }}>Slider Login </Label><small> (Multiple Input)</small> |
|
|
|
|
<Input |
|
|
|
|
type="file" |
|
|
|
|
accept="image/*" |
|
|
|
|
multiple |
|
|
|
|
onChange={(e) => setSliderLogin(e.target.files)} |
|
|
|
|
/> |
|
|
|
|
<small onClick={imageSlider.length ? () => handleImageClick('imageSlider') : ''} style={{ cursor: imageSlider.length ? "pointer" : ""}}> |
|
|
|
|
<p style={{ textDecoration: imageSlider.length ? 'underline' : 'none', color: imageSlider.length ? 'blue' : 'red' }}> |
|
|
|
|
{ |
|
|
|
|
imageSlider.length > 0 ? ( |
|
|
|
|
"View image" |
|
|
|
|
) : ( |
|
|
|
|
"Not found image" |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</p> |
|
|
|
|
</small> |
|
|
|
|
</FormGroup> |
|
|
|
|
</Row> |
|
|
|
|
<Row> |
|
|
|
@ -705,10 +760,18 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
accept="image/*" |
|
|
|
|
onChange={(e) => setLogoHeader(e.target.files[0])} |
|
|
|
|
/> |
|
|
|
|
<small>{imageHeader ? imageHeader.image : <p style={{ color: "red" }}>Not found image</p> }</small> |
|
|
|
|
<small onClick={imageHeader ? () => handleImageClick('imageHeader') : ''} style={{ cursor: imageHeader ? "pointer" : ""}}> |
|
|
|
|
<p style={{ textDecoration: imageHeader ? 'underline' : 'none', color: imageHeader ? 'blue' : 'red' }}> |
|
|
|
|
{ |
|
|
|
|
imageHeader ? ( |
|
|
|
|
"View image" |
|
|
|
|
) : ( |
|
|
|
|
"Not found image" |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</p> |
|
|
|
|
</small> |
|
|
|
|
</FormGroup> |
|
|
|
|
</Row> |
|
|
|
|
<Row> |
|
|
|
|
<FormGroup> |
|
|
|
|
<Label className="capitalize" style={{ fontWeight: "bold" }}>Favicon Logo</Label> |
|
|
|
|
<Input |
|
|
|
@ -716,12 +779,54 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
|
|
|
|
|
accept=".ico" |
|
|
|
|
onChange={(e) => setFavIcon(e.target.files[0])} |
|
|
|
|
/> |
|
|
|
|
<small>{imageFavIcon ? imageFavIcon.image : <p style={{ color: "red" }}>Not found image</p> }</small> |
|
|
|
|
<small onClick={imageFavIcon ? () => handleImageClick('favIcon') : ''} style={{ cursor: imageFavIcon ? "pointer" : "" }}> |
|
|
|
|
<p style={{ textDecoration: imageFavIcon ? 'underline' : 'none', color: imageFavIcon ? 'blue' : 'red' }}> |
|
|
|
|
{ |
|
|
|
|
imageFavIcon ? ( |
|
|
|
|
"View image" |
|
|
|
|
) : ( |
|
|
|
|
"Not found image" |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</p> |
|
|
|
|
</small> |
|
|
|
|
</FormGroup> |
|
|
|
|
</Row> |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
|
</Form> |
|
|
|
|
<Modal isOpen={modalOpen} toggle={toggleModal}> |
|
|
|
|
<ModalBody> |
|
|
|
|
{ |
|
|
|
|
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 : '') |
|
|
|
|
} |
|
|
|
|
style={{ maxWidth: "100%" }} |
|
|
|
|
alt="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> |
|
|
|
|
</Col> |
|
|
|
|
))} |
|
|
|
|
</Row> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</ModalBody> |
|
|
|
|
<ModalFooter> |
|
|
|
|
<Button color="secondary" onClick={toggleModal}>Close</Button> |
|
|
|
|
</ModalFooter> |
|
|
|
|
</Modal> |
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|