Skip to content

Commit

Permalink
new fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelmd-eGov committed May 28, 2024
1 parent 8e8b0e1 commit 20f9047
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ const CampaignDates = ({ onSelect, formData, ...props }) => {

useEffect(() => {
if (props?.props?.isSubmitting && !endDate && !startDate) {
setError({ startDate: "CAMPAIGN_FIELD_MANDATORY", endDate: "CAMPAIGN_FIELD_MANDATORY" })
setError({ startDate: "CAMPAIGN_FIELD_MANDATORY", endDate: "CAMPAIGN_FIELD_MANDATORY" });
} else if (props?.props?.isSubmitting && !startDate) {
setError({ startDate: "CAMPAIGN_FIELD_MANDATORY" })
setError({ startDate: "CAMPAIGN_FIELD_MANDATORY" });
} else if (props?.props?.isSubmitting && !endDate) {
setError({ endDate: "CAMPAIGN_FIELD_MANDATORY" })
setError({ endDate: "CAMPAIGN_FIELD_MANDATORY" });
} else {
setError(null)
setError(null);
}
}, [props?.props?.isSubmitting])
}, [props?.props?.isSubmitting]);
useEffect(() => {
if (!startDate && startValidation) {
setError({ startDate: "CAMPAIGN_START_DATE_ERROR" });
} else if (!endDate && startValidation) {
setError({ endDate: "CAMPAIGN_END_DATE_ERROR" });
} else if ((new Date(endDate).getTime() < new Date(startDate).getTime()) && startValidation) {
setError({ endDate: "CAMPAIGN_END_DATE_BEFORE_ERROR" })
} else if (new Date(endDate).getTime() < new Date(startDate).getTime() && startValidation) {
setError({ endDate: "CAMPAIGN_END_DATE_BEFORE_ERROR" });
} else if (startDate || endDate) {
setError(null);
onSelect("campaignDates", { startDate: startDate, endDate: endDate });
Expand All @@ -53,7 +53,7 @@ const CampaignDates = ({ onSelect, formData, ...props }) => {
useEffect(() => {
if (executionCount < 5) {
onSelect("campaignDates", { startDate: startDate, endDate: endDate });
setExecutionCount(prevCount => prevCount + 1);
setExecutionCount((prevCount) => prevCount + 1);
}
});

Expand Down Expand Up @@ -83,11 +83,11 @@ const CampaignDates = ({ onSelect, formData, ...props }) => {
placeholder={t("HCM_START_DATE")}
min={Digit.Utils.date.getDate(Date.now() + ONE_DAY_IN_MS)}
onChange={(d) => {
setStartValidation(true)
setStart(d)
setStartValidation(true);
setStart(d);
}}
/>
{error?.startDate && <ErrorMessage message={error?.startDate} showIcon={true} />}
{error?.startDate && <ErrorMessage message={t(error?.startDate)} showIcon={true} />}
</div>
<div>
<TextInput
Expand All @@ -97,11 +97,11 @@ const CampaignDates = ({ onSelect, formData, ...props }) => {
placeholder={t("HCM_END_DATE")}
min={Digit.Utils.date.getDate(Date.now() + 2 * ONE_DAY_IN_MS)}
onChange={(d) => {
setStartValidation(true)
setEnd(d)
setStartValidation(true);
setEnd(d);
}}
/>
{error?.endDate && <ErrorMessage message={error?.endDate} showIcon={true} />}
{error?.endDate && <ErrorMessage message={t(error?.endDate)} showIcon={true} />}
</div>
</div>
</LabelFieldPair>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const CampaignName = ({ onSelect, formData, control, formState, ...props }) => {

useEffect(() => {
if (props?.props?.isSubmitting && !name) {
setError({ message: "CAMPAIGN_FIELD_MANDATORY" })
setError({ message: "CAMPAIGN_FIELD_MANDATORY" });
} else {
setError(null)
setError(null);
}
}, [props?.props?.isSubmitting])
}, [props?.props?.isSubmitting]);
useEffect(() => {
if (startValidation && !name) {
setError({ message: "CAMPAIGN_NAME_ERROR" })
setError({ message: "CAMPAIGN_NAME_ERROR" });
} else if (name) {
setError(null)
setError(null);
onSelect("campaignName", name);
}
}, [name, props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName]);
Expand All @@ -47,11 +47,17 @@ const CampaignName = ({ onSelect, formData, control, formState, ...props }) => {
<span className="mandatory-span">*</span>
</div>
<div>
<TextInput error={!!error} style={{ width: "40rem", marginBottom: "0" }} name="campaignName" value={name} onChange={(event) => {
setStartValidation(true);
setName(event.target.value);
}} />
{error?.message && <ErrorMessage message={error?.message} showIcon={true} />}
<TextInput
error={!!error}
style={{ width: "40rem", marginBottom: "0" }}
name="campaignName"
value={name}
onChange={(event) => {
setStartValidation(true);
setName(event.target.value);
}}
/>
{error?.message && <ErrorMessage message={t(error?.message)} showIcon={true} />}
</div>
</LabelFieldPair>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {

useEffect(() => {
if (props?.props?.isSubmitting && !type) {
setError({ message: "CAMPAIGN_FIELD_MANDATORY" })
setError({ message: "CAMPAIGN_FIELD_MANDATORY" });
}
}, [props?.props?.isSubmitting])
}, [props?.props?.isSubmitting]);
useEffect(() => {
setType(props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType);
setBeneficiaryType(props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType?.beneficiaryType);
Expand All @@ -34,9 +34,9 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {

useEffect(() => {
if (!type && startValidation) {
setError({ message: "CAMPAIGN_FIELD_MANDATORY" })
setError({ message: "CAMPAIGN_FIELD_MANDATORY" });
} else {
setError(null)
setError(null);
onSelect("projectType", type);
}
}, [type]);
Expand Down Expand Up @@ -69,7 +69,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
handleChange(value);
}}
/>
{error?.message && <ErrorMessage wrapperStyles={{ marginTop: "-10px" }} message={error?.message} showIcon={true} />}
{error?.message && <ErrorMessage wrapperStyles={{ marginTop: "-10px" }} message={t(error?.message)} showIcon={true} />}
</div>
</LabelFieldPair>
{showBeneficiary && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,32 @@ export const deliveryConfig = [
cycle: 1,
deliveries: 1,
},
attributeConfig: [
{
key: 1,
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_INDIVIDUAL_LABEL",
},
deliveryConfig: [
{
key: 2,
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_HOUSEHOLD_LABEL",
attributeConfig: [
{
key: 1,
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_INDIVIDUAL_LABEL",
},
{
key: 2,
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_HOUSEHOLD_LABEL",
},
],
productConfig: [
{
key: 1,
count: 1,
value: "PVAR-2024-05-03-000305",
name: "SP - 250mg",
},
],
},
],
deliveryConfig: [
{
delivery: 1,
conditionConfig: [{
attributeConfig: [
{
key: 1,
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_INDIVIDUAL_LABEL",
operatorValue: "LESS_THAN_EQUAL_TO",
value: 3,
},
{
key: 2,
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_HOUSEHOLD_LABEL",
operatorValue: "LESS_THAN_EQUAL_TO",
value: 1.8,
},
],
productConfig: [
{
key: 1,
count: 1,
value: "PVAR-2024-02-09-000150",
name: "Bednet - 500mg",
},
],
},
]
}],
},
{
projectType: "MR-DN",
Expand Down Expand Up @@ -119,7 +98,7 @@ export const deliveryConfig = [
},
],
},
]
],
},
{
delivery: 2,
Expand Down Expand Up @@ -173,8 +152,8 @@ export const deliveryConfig = [
},
],
},
]
}
],
},
],
},
];
Loading

0 comments on commit 20f9047

Please sign in to comment.