Skip to content

Commit

Permalink
merges pr coronasafe#7339
Browse files Browse the repository at this point in the history
  • Loading branch information
UdaySagar-Git committed Mar 26, 2024
1 parent d467c35 commit 12a8f1e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Components/ExternalResult/ExternalResultImportModal.tsx
Expand Up @@ -22,11 +22,31 @@ export default function ExternalResultImportModal({ open, onClose }: Props) {
const [loading, setLoading] = useState(false);

const fetchUser = async () => {
const { data: userData } = await request(routes.currentUser, {
const { data: user } = await request(routes.currentUser, {
pathParams: {},
});

ExternalResultImportSchema.Address.parse = (value: string) => {
if (
user?.user_type === "StateAdmin" ||
user?.user_type === "StateLabAdmin"
) {
if (value.split(",").pop()?.trim() === user?.state_object?.name) {
return value;
} else {
throw new Error("State should be the same as the user's state");
}
}
return value;
};

ExternalResultImportSchema.District.parse = (value: string) => {
if (value !== userData?.district_object?.name) {
if (
user?.user_type === "StateAdmin" ||
user?.user_type === "StateLabAdmin"
) {
return value;
} else if (value !== user?.district_object?.name) {
throw new Error("District should be the same as the user's district");
}
};
Expand Down

0 comments on commit 12a8f1e

Please sign in to comment.