From 1e3ee04b340c241738b54ad5588c88f5c47b14c2 Mon Sep 17 00:00:00 2001 From: Eman Date: Mon, 16 Dec 2024 18:04:23 +0300 Subject: [PATCH] feat: order status update guides --- .../OrderProgress/UpdateOrderStatusForm.tsx | 66 ++++++++++++++++--- packages/ui/components/IconButton.tsx | 2 +- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/packages/features/Orders/OrderProgress/UpdateOrderStatusForm.tsx b/packages/features/Orders/OrderProgress/UpdateOrderStatusForm.tsx index a4fbab0a..7ab0418c 100644 --- a/packages/features/Orders/OrderProgress/UpdateOrderStatusForm.tsx +++ b/packages/features/Orders/OrderProgress/UpdateOrderStatusForm.tsx @@ -4,7 +4,7 @@ import { useState } from "react" import { z } from "zod" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" -import { Card } from "ui" +import { Button, Card, IconButton } from "ui" import { Orders, Order_Status_Enum, @@ -18,7 +18,9 @@ import { HiOutlineArchiveBox, HiOutlineXCircle, HiCalendarDays, - HiArrowRight + HiArrowRight, + HiArrowPathRoundedSquare, + HiOutlineInformationCircle } from "react-icons/hi2" import toast from "react-hot-toast" @@ -91,6 +93,7 @@ const STATUS_INFO = { export const UpdateOrderStatusForm = ({ order }: Props) => { const { appendOrderStatus, loading } = useAppendOrderStatus() const [showNote, setShowNote] = useState(false) + const [showStatusInfo, setShowStatusInfo] = useState(false) const currentStatus = order.status_histories?.[0]?.status || "PENDING" const { @@ -125,7 +128,7 @@ export const UpdateOrderStatusForm = ({ order }: Props) => { } return ( - +
{/* Current Status */}
@@ -154,7 +157,14 @@ export const UpdateOrderStatusForm = ({ order }: Props) => { {/* Available Status Updates */} {availableStatuses.length > 0 && (
-

Update Status

+
+

Update Status

+ setShowStatusInfo(true)} + title="View status flow information" + /> +
{availableStatuses.map((status) => { @@ -211,7 +221,7 @@ export const UpdateOrderStatusForm = ({ order }: Props) => { className="btn btn-sm btn-primary" disabled={loading} > - Update Status + Confirm
)} +
Status History
+ {/* Status History */}
-

Status History

{order.status_histories?.map((history, index) => { const statusInfo = STATUS_INFO[history.status as keyof typeof STATUS_INFO] @@ -254,7 +265,46 @@ export const UpdateOrderStatusForm = ({ order }: Props) => {
+ + {/* Status Flow Information Dialog */} + +
+

Order Status Flow

+
+ {Object.entries(STATUS_FLOW).map(([status, nextStatuses]) => { + const statusInfo = STATUS_INFO[status as keyof typeof STATUS_INFO] + return ( +
+
+
+ +
+ + {status} +
+
+ {nextStatuses.length > 0 ? ( +
+ Can be updated to: {nextStatuses.join(', ')} +
+ ) : ( +
+ Final status - no further updates possible +
+ )} +
+
+ ) + })} +
+
+ +
+
+
+ +
+
) } - diff --git a/packages/ui/components/IconButton.tsx b/packages/ui/components/IconButton.tsx index c483c7ce..08a622f2 100644 --- a/packages/ui/components/IconButton.tsx +++ b/packages/ui/components/IconButton.tsx @@ -9,7 +9,7 @@ export type IconButtonProps = IconProps & { }; export const IconButton: FC = ({ className, icon, title, onClick }) => { - const merged = twMerge("btn btn-xs btn-square", className); + const merged = twMerge("btn btn-xs btn-circle btn-ghost", className); return (