conditions changed in remarks
This commit is contained in:
parent
4db00f84fd
commit
465cc8f9b0
@ -139,6 +139,24 @@ const formatDate = (dateString) => {
|
|||||||
return `${day}/${month}/${year}`;
|
return `${day}/${month}/${year}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const extractIndustryCode = (value) => {
|
||||||
|
if (value === null || value === undefined) return '';
|
||||||
|
const normalized = String(value).trim();
|
||||||
|
if (!normalized) return '';
|
||||||
|
|
||||||
|
const leadingDigits = normalized.match(/^(\d+)/);
|
||||||
|
const beforeDash = normalized.split('-')[0]?.trim();
|
||||||
|
const rawCode = (leadingDigits?.[1] ?? beforeDash ?? normalized);
|
||||||
|
|
||||||
|
return String(rawCode).trim().replace(/^0+(?=\d)/, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
const getIndustryCodeFromIsicSelection = (selectedValue, options = []) => {
|
||||||
|
if (selectedValue === null || selectedValue === undefined || selectedValue === '') return '';
|
||||||
|
const selected = options.find((opt) => String(opt?.value) === String(selectedValue));
|
||||||
|
return extractIndustryCode(selected?.label ?? selectedValue);
|
||||||
|
};
|
||||||
|
|
||||||
const createEmptyProfile = () => ({
|
const createEmptyProfile = () => ({
|
||||||
apiId: null,
|
apiId: null,
|
||||||
userProfileName: '',
|
userProfileName: '',
|
||||||
@ -1066,7 +1084,7 @@ const CompanyProfile = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{form.industryCodeProduction && form.industryCodeBusiness && form.industryCodeBusiness !== form.industryCodeProduction && (
|
{form.industryCodeProduction && form.industryCodeBusiness && extractIndustryCode(form.industryCodeBusiness) !== getIndustryCodeFromIsicSelection(form.industryCodeProduction, isicOptions) && (
|
||||||
<div className="mt-4 w-[calc(100%-1px)]">
|
<div className="mt-4 w-[calc(100%-1px)]">
|
||||||
<TextField
|
<TextField
|
||||||
label="Remarks"
|
label="Remarks"
|
||||||
|
|||||||
@ -81,11 +81,30 @@ const computeEmploymentTotals = (data) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const extractIndustryCode = (value) => {
|
||||||
|
if (value === null || value === undefined) return '';
|
||||||
|
const normalized = String(value).trim();
|
||||||
|
if (!normalized) return '';
|
||||||
|
|
||||||
|
const leadingDigits = normalized.match(/^(\d+)/);
|
||||||
|
const beforeDash = normalized.split('-')[0]?.trim();
|
||||||
|
const rawCode = (leadingDigits?.[1] ?? beforeDash ?? normalized);
|
||||||
|
|
||||||
|
return String(rawCode).trim().replace(/^0+(?=\d)/, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
const getIndustryCodeFromIsicSelection = (selectedValue, options = []) => {
|
||||||
|
if (selectedValue === null || selectedValue === undefined || selectedValue === '') return '';
|
||||||
|
const selected = options.find((opt) => String(opt?.value) === String(selectedValue));
|
||||||
|
return extractIndustryCode(selected?.label ?? selectedValue);
|
||||||
|
};
|
||||||
|
|
||||||
const EditCompanyProfile = () => {
|
const EditCompanyProfile = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { id: establishmentId } = useParams();
|
const { id: establishmentId } = useParams();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [form, setForm] = useState(createEmptyProfile());
|
const [form, setForm] = useState(createEmptyProfile());
|
||||||
|
|
||||||
const [activeStep, setActiveStep] = useState(0);
|
const [activeStep, setActiveStep] = useState(0);
|
||||||
const [fieldErrors, setFieldErrors] = useState({});
|
const [fieldErrors, setFieldErrors] = useState({});
|
||||||
const [passwordError, setPasswordError] = useState("");
|
const [passwordError, setPasswordError] = useState("");
|
||||||
@ -935,7 +954,7 @@ const EditCompanyProfile = () => {
|
|||||||
rows={3}
|
rows={3}
|
||||||
/> */}
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
{form.industryCodeBusiness && form.industryCodeBusiness !== form.industryCodeCurrent && (
|
{form.industryCodeBusiness && extractIndustryCode(form.industryCodeBusiness) !== getIndustryCodeFromIsicSelection(form.industryCodeCurrent, isicOptions) && (
|
||||||
<div className="col-span-full">
|
<div className="col-span-full">
|
||||||
<TextField
|
<TextField
|
||||||
label="Remarks"
|
label="Remarks"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user