conditions changed in remarks

This commit is contained in:
Malini 2026-02-23 12:17:57 +05:30
parent 4db00f84fd
commit 465cc8f9b0
2 changed files with 53 additions and 16 deletions

View File

@ -139,6 +139,24 @@ const formatDate = (dateString) => {
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 = () => ({
apiId: null,
userProfileName: '',
@ -1066,7 +1084,7 @@ const CompanyProfile = () => {
</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)]">
<TextField
label="Remarks"

View File

@ -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 navigate = useNavigate();
const { id: establishmentId } = useParams();
const [loading, setLoading] = useState(false);
const [form, setForm] = useState(createEmptyProfile());
const [activeStep, setActiveStep] = useState(0);
const [fieldErrors, setFieldErrors] = useState({});
const [passwordError, setPasswordError] = useState("");
@ -935,7 +954,7 @@ const EditCompanyProfile = () => {
rows={3}
/> */}
</div>
{form.industryCodeBusiness && form.industryCodeBusiness !== form.industryCodeCurrent && (
{form.industryCodeBusiness && extractIndustryCode(form.industryCodeBusiness) !== getIndustryCodeFromIsicSelection(form.industryCodeCurrent, isicOptions) && (
<div className="col-span-full">
<TextField
label="Remarks"