Skip to content

Commit

Permalink
Merge branch 'abdm-m3' of github.com:coronasafe/care_fe into abdm-m3
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed Feb 18, 2024
2 parents a662788 + 25acb6c commit f7c1a2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
8 changes: 6 additions & 2 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ class FacilityManage {
cy.get("#hf_id").click().clear().click().type(address);
}

verifySuccessMessageVisibilityAndContent(text) {
cy.get(".pnotify-text").should("be.visible").contains(text);
verifySuccessMessageVisibilityAndContent(text, isRegex = false) {
if (isRegex) {
cy.get(".pnotify-text").should("be.visible").contains(text);
} else {
cy.get(".pnotify-text").should("be.visible").and("contain.text", text);
}
}

verifyMiddlewareAddressValue(expectedValue) {
Expand Down
30 changes: 10 additions & 20 deletions src/Components/ExternalResult/ExternalResultUpload.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from "lodash-es";
import { navigate } from "raviger";
import { lazy, useEffect, useState } from "react";
import { lazy, useState } from "react";
import CSVReader from "react-csv-reader";
import useConfig from "../../Common/hooks/useConfig";
import * as Notification from "../../Utils/Notifications.js";
Expand All @@ -12,6 +12,7 @@ import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import { IExternalResult } from "./models";
import CareIcon from "../../CAREUI/icons/CareIcon";
import useAuthUser from "../../Common/hooks/useAuthUser";

export default function ExternalResultUpload() {
const { sample_format_external_result_import } = useConfig();
Expand All @@ -20,30 +21,18 @@ export default function ExternalResultUpload() {
const [csvData, setCsvData] = useState(new Array<IExternalResult>());
const [errors, setErrors] = useState<any>([]);
const [validationErrorCount, setValidationErrorCount] = useState(0);
const [user, setUser] = useState<any>({});
const handleForce = (data: any) => {
const authUser = useAuthUser();
const handleForce = (data: IExternalResult[]) => {
setCsvData(data);
setValidationErrorCount(
data.filter(
(result: IExternalResult) =>
result.district !== user.district_object.name
(result) => String(result.district) !== authUser.district_object?.name
).length
);
};
const { t } = useTranslation();
const { goBack } = useAppHistory();

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

useEffect(() => {
fetchUser();
}, []);

const papaparseOptions = {
header: true,
dynamicTyping: true,
Expand All @@ -67,7 +56,7 @@ export default function ExternalResultUpload() {
sample_tests: validationErrorCount
? csvData.filter(
(data: IExternalResult) =>
data.district === user.district_object.name
String(data.district) !== authUser.district_object?.name
)
: csvData,
},
Expand Down Expand Up @@ -118,7 +107,7 @@ export default function ExternalResultUpload() {
<span className="flex justify-center">
<svg
xmlns="http://www.w3.org/2000/svg"
className="mb-2 h-12 w-12 text-gray-700"
className="mb-2 size-12 text-gray-700"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
Expand Down Expand Up @@ -156,7 +145,7 @@ export default function ExternalResultUpload() {
<p className="flex justify-end p-2">Total: {csvData.length}</p>
)}
<div className=" rounded bg-white shadow">
{csvData.map((data: any, index: number) => {
{csvData.map((data, index: number) => {
return (
<div key={data.name} className="flex border-b p-2">
<div className="mr-2 p-2">{index + 1}</div>
Expand All @@ -175,7 +164,8 @@ export default function ExternalResultUpload() {
: null}
</div>
<div>
{data.district !== user.district_object.name && (
{String(data.district) !==
authUser.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 f7c1a2a

Please sign in to comment.