feat(inquiries): Add change status functionality to inquiries
- Create ChangeStatusForm component with status, reason, and description fields - Add change status modal to inquiries table with form integration - Implement useChangeInquiryStatus hook integration in presenter - Add edit icon button to trigger status change modal for each inquiry - Update Status component to accept status prop for proper styling - Update FormFooter component to support form submission handling - Add isChangeStatusModalOpen state management to presenter - Update TInquiries type definitions to include change status credentials - Enhance inquiries list with status change workflow alongside existing delete functionality
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
import {
|
||||
useChangeInquiryStatus,
|
||||
useDeleteInquiry,
|
||||
useGetInquiries,
|
||||
} from "@/hooks/queries/useInquiryQueries";
|
||||
@@ -13,6 +14,7 @@ import { useForm } from "react-hook-form";
|
||||
const useInquiriesListPresenter = () => {
|
||||
const [isFilterModalOpen, setIsFilterModalOpen] = useState(false);
|
||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||
const [isChangeStatusModalOpen, setIsChangeStatusModalOpen] = useState(false);
|
||||
const [currentInquiry, setCurrentInquiry] = useState<TInquiries | null>(null);
|
||||
const [params, setParams] = useState<Record<string, any>>({});
|
||||
const columns = [
|
||||
@@ -51,6 +53,8 @@ const useInquiriesListPresenter = () => {
|
||||
|
||||
const { data, isPending } = useGetInquiries(params);
|
||||
const { mutate } = useDeleteInquiry(() => setIsDeleteModalOpen(false));
|
||||
const { mutate: changeStatus, isPending: isChangingStatus } =
|
||||
useChangeInquiryStatus(() => setIsChangeStatusModalOpen(false));
|
||||
|
||||
const search = (data: any) => {
|
||||
const newParams = { ...params, ...data, offset: 0 };
|
||||
@@ -65,6 +69,14 @@ const useInquiriesListPresenter = () => {
|
||||
mutate(currentInquiry.id);
|
||||
};
|
||||
|
||||
const handleChangeStatus = (data: any) => {
|
||||
if (!currentInquiry?.id) return;
|
||||
changeStatus({
|
||||
id: currentInquiry.id,
|
||||
credentials: data,
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
columns,
|
||||
inquiries: data?.data.inquiries,
|
||||
@@ -74,9 +86,13 @@ const useInquiriesListPresenter = () => {
|
||||
isPending,
|
||||
isDeleteModalOpen,
|
||||
setIsDeleteModalOpen,
|
||||
isChangeStatusModalOpen,
|
||||
setIsChangeStatusModalOpen,
|
||||
currentInquiry,
|
||||
setCurrentInquiry,
|
||||
deleteInquiry,
|
||||
handleChangeStatus,
|
||||
isChangingStatus,
|
||||
filterRegister,
|
||||
handleFilterSubmit,
|
||||
search,
|
||||
|
||||
Reference in New Issue
Block a user