From ccf886f9c6382454e8e76f00a57610e429c218e2 Mon Sep 17 00:00:00 2001 From: Saikiran Patil <84263946+saikiranpatil@users.noreply.github.com> Date: Sat, 28 Dec 2024 22:47:15 +0530 Subject: [PATCH] used shadcn buttons in location management page --- src/components/Common/AuthorizedButton.tsx | 2 +- src/components/Common/CancelButton.tsx | 32 ++++++ src/components/Facility/FacilityConfigure.tsx | 3 +- .../Facility/LocationManagement.tsx | 107 +++++++++++------- 4 files changed, 99 insertions(+), 45 deletions(-) create mode 100644 src/components/Common/CancelButton.tsx diff --git a/src/components/Common/AuthorizedButton.tsx b/src/components/Common/AuthorizedButton.tsx index 2b611a0c9f2..94eca834f00 100644 --- a/src/components/Common/AuthorizedButton.tsx +++ b/src/components/Common/AuthorizedButton.tsx @@ -5,7 +5,7 @@ import AuthorizedChild from "@/CAREUI/misc/AuthorizedChild"; import { AuthorizedElementProps } from "@/Utils/AuthorizeFor"; export const AuthorizedButton: React.FC< - AuthorizedElementProps & ButtonProps + AuthorizedElementProps & ButtonProps & { variant?: string } > = ({ authorizeFor = () => true, ...props }) => { return ( diff --git a/src/components/Common/CancelButton.tsx b/src/components/Common/CancelButton.tsx new file mode 100644 index 00000000000..092fbac5398 --- /dev/null +++ b/src/components/Common/CancelButton.tsx @@ -0,0 +1,32 @@ +import { useTranslation } from "react-i18next"; + +import { cn } from "@/lib/utils"; + +import CareIcon from "@/CAREUI/icons/CareIcon"; + +import { Button, ButtonProps } from "@/components/ui/button"; + +export interface CancelButtonProps extends ButtonProps { + label?: string; +} + +const CancelButton = ({ label = "Cancel", ...props }: CancelButtonProps) => { + const { t } = useTranslation(); + return ( + + ); +}; + +export default CancelButton; diff --git a/src/components/Facility/FacilityConfigure.tsx b/src/components/Facility/FacilityConfigure.tsx index 8dee8f47163..af4816de0c7 100644 --- a/src/components/Facility/FacilityConfigure.tsx +++ b/src/components/Facility/FacilityConfigure.tsx @@ -8,6 +8,7 @@ import { z } from "zod"; import CareIcon from "@/CAREUI/icons/CareIcon"; +import { Button } from "@/components/ui/button"; import { Form, FormControl, @@ -28,8 +29,6 @@ import routes from "@/Utils/request/api"; import mutate from "@/Utils/request/mutate"; import query from "@/Utils/request/query"; -import { Button } from "../ui/button"; - interface IProps { facilityId: string; } diff --git a/src/components/Facility/LocationManagement.tsx b/src/components/Facility/LocationManagement.tsx index e9c1323142f..36cd3ce1c26 100644 --- a/src/components/Facility/LocationManagement.tsx +++ b/src/components/Facility/LocationManagement.tsx @@ -1,4 +1,5 @@ import { useQuery } from "@tanstack/react-query"; +import { navigate } from "raviger"; import { useState } from "react"; import RecordMeta from "@/CAREUI/display/RecordMeta"; @@ -6,8 +7,16 @@ import CareIcon from "@/CAREUI/icons/CareIcon"; import PaginatedList from "@/CAREUI/misc/PaginatedList"; import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; -import ButtonV2, { Cancel } from "@/components/Common/ButtonV2"; +import { AuthorizedButton } from "@/components/Common/AuthorizedButton"; +import CancelButton from "@/components/Common/CancelButton"; import ConfirmDialog from "@/components/Common/ConfirmDialog"; import DialogModal from "@/components/Common/Dialog"; import Loading from "@/components/Common/Loading"; @@ -101,26 +110,26 @@ export default function LocationManagement({ facilityId }: Props) { title="Location Management" backUrl={`/facility/${facilityId}`} options={ - navigate(`/facility/${facilityId}/location/add`)} authorizeFor={NonReadOnlyUsers} className="hidden lg:block" > Add New Location - + } >
- navigate(`/facility/${facilityId}/location/add`)} authorizeFor={NonReadOnlyUsers} className="w-full lg:hidden" > Add New Location - +
@@ -186,19 +195,23 @@ export default function LocationManagement({ facilityId }: Props) { deleted first before the location can be removed
- { closeDeleteFailModal(); }} /> - + navigate( + `/facility/${facilityId}/location/${showDeleteFailModal.id}/beds`, + ) + } authorizeFor={NonReadOnlyUsers} className="w-full" > Manage Beds - +
) : ( @@ -208,19 +221,23 @@ export default function LocationManagement({ facilityId }: Props) { be deleted first before the location can be removed
- { closeDeleteFailModal(); }} /> - + navigate( + `/assets?page=1&limit=18&facility=${facilityId}&asset_type=&asset_class=&status=&location=${showDeleteFailModal.id}&warranty_amc_end_of_validity_before=&warranty_amc_end_of_validity_after=`, + ) + } authorizeFor={NonReadOnlyUsers} className="w-full" > Manage Assets - +
)} @@ -305,12 +322,11 @@ const Location = ({ /> - navigate(`location/${id}/beds`)} disabled={totalBeds == null} > Manage Beds @@ -318,39 +334,46 @@ const Location = ({ {totalBeds ?? "--"} - +
- navigate(`location/${id}/update`)} authorizeFor={NonReadOnlyUsers} > Edit - +
- - setShowDeletePopup({ open: true, name: name ?? "", id: id ?? "" }) - } - > - - Delete - + + + + + setShowDeletePopup({ + open: true, + name: name ?? "", + id: id ?? "", + }) + } + > + + Delete + + + + {disabled ? "Contact your admin to delete the location" : ""} + + +