Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace useDispatch with useQuery/request in facility module (Part 2, E-Z) (src/Components/Facility/[E-Z]*.tsx #6448

Closed
wants to merge 13 commits into from
Closed
19 changes: 9 additions & 10 deletions src/Components/Facility/FacilityCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { useState } from "react";
import { useDispatch } from "react-redux";
import { Link } from "raviger";
import { useTranslation } from "react-i18next";

import { sendNotificationMessages } from "../../Redux/actions";
import { FACILITY_FEATURE_TYPES } from "../../Common/constants";
import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2";
import * as Notification from "../../Utils/Notifications.js";
Expand All @@ -14,25 +11,27 @@ import DialogModal from "../Common/Dialog";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import useConfig from "../../Common/hooks/useConfig";
import { classNames } from "../../Utils/utils";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";

export const FacilityCard = (props: { facility: any; userType: any }) => {
const { facility, userType } = props;
const { kasp_string } = useConfig();

const { t } = useTranslation();
const dispatchAction: any = useDispatch();
const [notifyModalFor, setNotifyModalFor] = useState(undefined);
const [notifyMessage, setNotifyMessage] = useState("");
const [notifyError, setNotifyError] = useState("");

const handleNotifySubmit = async (id: any) => {
const data = {
facility: id,
message: notifyMessage,
};
if (data.message.trim().length >= 1) {
if (notifyMessage.trim().length >= 1) {
setNotifyError("");
const res = await dispatchAction(sendNotificationMessages(data));
const { res } = await request(routes.sendNotificationMessages, {
body: {
facility: id,
message: notifyMessage,
},
});
if (res && res.status == 204) {
Notification.Success({
msg: "Facility Notified",
Expand Down
Loading