Skip to content

Commit

Permalink
Refactored condition of Different Districts in External Result
Browse files Browse the repository at this point in the history
  • Loading branch information
jainvedant392 committed Mar 5, 2024
1 parent cd23b66 commit 16d2d79
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Components/ExternalResult/ExternalResultUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ export default function ExternalResultUpload() {
setValidationErrorCount(
data.filter(
(result: IExternalResult) =>
result.district !== user.district_object.name
(user.user_type === "StateAdmin" &&
result.address.split(",").pop()?.trim() !==
user.state_object.name) ||
(user.user_type !== "StateAdmin" &&
result.district !== user.district_object.name)
).length
);
};
console.log("validationErrorCount", validationErrorCount);
const { t } = useTranslation();
const { goBack } = useAppHistory();

Expand Down Expand Up @@ -67,7 +72,11 @@ export default function ExternalResultUpload() {
sample_tests: validationErrorCount
? csvData.filter(
(data: IExternalResult) =>
data.district === user.district_object.name
(user.user_type === "StateAdmin" &&
data.address.split(",").pop()?.trim() !==
user.state_object.name) ||
(user.user_type !== "StateAdmin" &&
data.district !== user.district_object.name)
)
: csvData,
},
Expand Down Expand Up @@ -179,7 +188,11 @@ export default function ExternalResultUpload() {
: null}
</div>
<div>
{data.district !== user.district_object.name && (
{((user.user_type === "StateAdmin" &&
data.address.split(",").pop()?.trim() !==
user.state_object.name) ||
(user.user_type !== "StateAdmin" &&
data.district !== user.district_object.name)) && (
<p className="mt-2 flex items-center justify-center gap-1 text-red-500">
<CareIcon icon="l-exclamation-triangle" /> Different
districts
Expand Down

0 comments on commit 16d2d79

Please sign in to comment.