Skip to content

Commit

Permalink
add sync to medicaid and chip spas (now just testing is left)
Browse files Browse the repository at this point in the history
  • Loading branch information
13bfrancis committed Mar 26, 2024
1 parent acd108c commit 29a7ec0
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 25 deletions.
21 changes: 16 additions & 5 deletions src/services/ui/src/features/actions/IssueRai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Path, useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { Info } from "lucide-react";
import { opensearch, Authority } from "shared-types";
import { opensearch, Authority, SEATOOL_STATUS } from "shared-types";

import {
Button,
Expand Down Expand Up @@ -35,6 +35,7 @@ import {
useOriginPath,
} from "@/utils";
import { useQuery as useQueryString } from "@/hooks";
import { useSyncStatus } from "@/hooks/useSyncStatus";

export const RaiIssue = ({
item,
Expand All @@ -51,10 +52,20 @@ export const RaiIssue = ({
const modal = useModalContext();
const alert = useAlertContext();
const originPath = useOriginPath();
const syncRecord = useSyncStatus({
path: originPath ? originPath : "/dashboard",
isCorrectStatus: (data) => {
return (
data._source.seatoolStatus === SEATOOL_STATUS.PENDING_RAI &&
!!data._source.raiRequestedDate
);
},
});
const acceptAction = useCallback(() => {
modal.setModalOpen(false);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
syncRecord(id);
}, [originPath]);

return (
<Form {...form}>
<form
Expand All @@ -76,10 +87,10 @@ export const RaiIssue = ({
// when any queries are added, such as the case of /details?id=...
urlQuery.get(ORIGIN)
? originRoute[urlQuery.get(ORIGIN)! as Origin]
: "/dashboard"
: "/dashboard",
);
navigate(
originPath ? { path: originPath } : { path: "/dashboard" }
originPath ? { path: originPath } : { path: "/dashboard" },
);
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -152,7 +163,7 @@ export const RaiIssue = ({
<li className="ml-8 my-2" key={idx}>
{err.message as string}
</li>
)
),
)}
</ul>
</Alert>
Expand Down
20 changes: 15 additions & 5 deletions src/services/ui/src/features/actions/RespondToRai.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from "react";
import { Path, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { opensearch, Authority } from "shared-types";
import { opensearch, Authority, SEATOOL_STATUS } from "shared-types";
import { Info } from "lucide-react";

import {
Expand Down Expand Up @@ -36,6 +36,7 @@ import {
useOriginPath,
} from "@/utils";
import { useQuery as useQueryString } from "@/hooks";
import { useSyncStatus } from "@/hooks/useSyncStatus";

export const RespondToRai = ({
item,
Expand All @@ -51,9 +52,18 @@ export const RespondToRai = ({
const modal = useModalContext();
const alert = useAlertContext();
const originPath = useOriginPath();
const syncRecord = useSyncStatus({
path: originPath ? originPath : "/dashboard",
isCorrectStatus: (data) => {
return (
data._source.seatoolStatus === SEATOOL_STATUS.PENDING &&
!!data._source.raiReceivedDate
);
},
});
const acceptAction = useCallback(() => {
modal.setModalOpen(false);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
syncRecord(id);
}, []);
const form = useForm({
resolver: zodResolver(schema),
Expand All @@ -80,10 +90,10 @@ export const RespondToRai = ({
// when any queries are added, such as the case of /details?id=...
urlQuery.get(ORIGIN)
? originRoute[urlQuery.get(ORIGIN)! as Origin]
: "/dashboard"
: "/dashboard",
);
navigate(
originPath ? { path: originPath } : { path: "/dashboard" }
originPath ? { path: originPath } : { path: "/dashboard" },
);
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -154,7 +164,7 @@ export const RespondToRai = ({
<li className="ml-8 my-2" key={idx}>
{err.message as string}
</li>
)
),
)}
</ul>
</Alert>
Expand Down
18 changes: 14 additions & 4 deletions src/services/ui/src/features/actions/ToggleRaiResponseWithdraw.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo } from "react";
import { Action, Authority, opensearch } from "shared-types";
import { Action, Authority, SEATOOL_STATUS, opensearch } from "shared-types";
import {
Navigate,
useNavigate,
Expand All @@ -20,6 +20,7 @@ import {
} from "@/utils";
import { ActionFormIntro, PackageInfo } from "@/features";
import { useQuery as useQueryString } from "@/hooks";
import { useSyncStatus } from "@/hooks/useSyncStatus";

export const ToggleRaiResponseWithdraw = ({
item,
Expand All @@ -33,9 +34,18 @@ export const ToggleRaiResponseWithdraw = ({
const modal = useModalContext();
const alert = useAlertContext();
const originPath = useOriginPath();
const syncRecord = useSyncStatus({
path: originPath ? originPath : "/dashboard",
isCorrectStatus: (data) => {
return (
data._source.seatoolStatus === SEATOOL_STATUS.PENDING &&
!!data._source.raiReceivedDate
);
},
});
const acceptAction = useCallback(() => {
modal.setModalOpen(false);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
syncRecord(id);
}, []);
const { mutate, isLoading, isSuccess, error } = useSubmissionService<{
id: string;
Expand All @@ -48,7 +58,7 @@ export const ToggleRaiResponseWithdraw = ({

const ACTION_WORD = useMemo(
() => (type === Action.ENABLE_RAI_WITHDRAW ? "Enable" : "Disable"),
[type]
[type],
);

useEffect(() => {
Expand All @@ -66,7 +76,7 @@ export const ToggleRaiResponseWithdraw = ({
// when any queries are added, such as the case of /details?id=...
urlQuery.get(ORIGIN)
? originRoute[urlQuery.get(ORIGIN)! as Origin]
: "/dashboard"
: "/dashboard",
);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
}
Expand Down
19 changes: 12 additions & 7 deletions src/services/ui/src/features/actions/WithdrawPackage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactElement, useCallback } from "react";
import { Path, useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { Authority, opensearch } from "shared-types";
import { Authority, SEATOOL_STATUS, opensearch } from "shared-types";
import { Info } from "lucide-react";
import {
Button,
Expand Down Expand Up @@ -35,6 +35,7 @@ import {
useOriginPath,
} from "@/utils";
import { useQuery as useQueryString } from "@/hooks";
import { useSyncStatus } from "@/hooks/useSyncStatus";

const attachmentInstructions: Record<SetupOptions, ReactElement> = {
"Medicaid SPA": (
Expand All @@ -53,9 +54,7 @@ const attachmentInstructions: Record<SetupOptions, ReactElement> = {

const addlInfoInstructions: Record<SetupOptions, ReactElement> = {
"Medicaid SPA": (
<p>
Explain your need for withdrawal, or upload supporting documentation.
</p>
<p>Explain your need for withdrawal, or upload supporting documentation.</p>
),
"CHIP SPA": <p>Explain your need for withdrawal.</p>,
};
Expand All @@ -77,6 +76,12 @@ export const WithdrawPackage = ({
const modal = useModalContext();
const alert = useAlertContext();
const originPath = useOriginPath();
const syncRecord = useSyncStatus({
path: originPath ? originPath : "/dashboard",
isCorrectStatus: (data) => {
return data._source.seatoolStatus === SEATOOL_STATUS.WITHDRAWN;
},
});
const cancelOnAccept = useCallback(() => {
modal.setModalOpen(false);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
Expand All @@ -101,9 +106,9 @@ export const WithdrawPackage = ({
// when any queries are added, such as the case of /details?id=...
urlQuery.get(ORIGIN)
? originRoute[urlQuery.get(ORIGIN)! as Origin]
: "/dashboard"
: "/dashboard",
);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
syncRecord(id);
} catch (e) {
console.error(e);
}
Expand Down Expand Up @@ -175,7 +180,7 @@ export const WithdrawPackage = ({
<li className="ml-8 my-2" key={idx}>
{err.message as string}
</li>
)
),
)}
</ul>
</Alert>
Expand Down
18 changes: 14 additions & 4 deletions src/services/ui/src/features/actions/WithdrawRai.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from "react";
import { Path, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { opensearch, Authority } from "shared-types";
import { opensearch, Authority, SEATOOL_STATUS } from "shared-types";
import { Info } from "lucide-react";
import {
Button,
Expand Down Expand Up @@ -33,6 +33,7 @@ import {
useOriginPath,
} from "@/utils";
import { useQuery as useQueryString } from "@/hooks";
import { useSyncStatus } from "@/hooks/useSyncStatus";

export const WithdrawRai = ({
item,
Expand All @@ -53,6 +54,15 @@ export const WithdrawRai = ({
modal.setModalOpen(false);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
}, []);
const syncRecord = useSyncStatus({
path: originPath ? originPath : "/dashboard",
isCorrectStatus: (data) => {
return (
data._source.seatoolStatus === SEATOOL_STATUS.PENDING_RAI &&
!!data._source.raiWithdrawnDate
);
},
});
const confirmOnAccept = useCallback(() => {
modal.setModalOpen(false);
form.handleSubmit(async (data) => {
Expand All @@ -73,9 +83,9 @@ export const WithdrawRai = ({
// when any queries are added, such as the case of /details?id=...
urlQuery.get(ORIGIN)
? originRoute[urlQuery.get(ORIGIN)! as Origin]
: "/dashboard"
: "/dashboard",
);
navigate(originPath ? { path: originPath } : { path: "/dashboard" });
syncRecord(id);
} catch (e) {
console.error(e);
}
Expand Down Expand Up @@ -139,7 +149,7 @@ export const WithdrawRai = ({
<li className="ml-8 my-2" key={idx}>
{err.message as string}
</li>
)
),
)}
</ul>
</Alert>
Expand Down

0 comments on commit 29a7ec0

Please sign in to comment.