feat: implement project development module, transfer management features, and industrial AVM model integration
This commit is contained in:
41
apps/web/lib/inquiry-store.ts
Normal file
41
apps/web/lib/inquiry-store.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
/**
|
||||
* UI state for the listing inquiry modal.
|
||||
*
|
||||
* Lives in a Zustand store so that:
|
||||
* - any component (e.g. floating CTAs, sticky "Nhắn tin" bars) can open the
|
||||
* modal without prop drilling through the listing detail tree
|
||||
* - tests and devtools can inspect / drive modal state directly
|
||||
*/
|
||||
export interface InquiryModalTarget {
|
||||
listingId: string;
|
||||
listingTitle: string;
|
||||
sellerName: string;
|
||||
}
|
||||
|
||||
export interface InquiryModalState {
|
||||
/** Whether the inquiry modal is currently open. */
|
||||
isOpen: boolean;
|
||||
/** The listing being inquired about (null when the modal is closed). */
|
||||
target: InquiryModalTarget | null;
|
||||
|
||||
/** Open the modal for a given listing. */
|
||||
openInquiry: (target: InquiryModalTarget) => void;
|
||||
/** Close the modal and clear the active target. */
|
||||
closeInquiry: () => void;
|
||||
/** Update open state directly (used by Radix onOpenChange). */
|
||||
setOpen: (open: boolean) => void;
|
||||
}
|
||||
|
||||
export const useInquiryStore = create<InquiryModalState>((set) => ({
|
||||
isOpen: false,
|
||||
target: null,
|
||||
openInquiry: (target) => set({ isOpen: true, target }),
|
||||
closeInquiry: () => set({ isOpen: false, target: null }),
|
||||
setOpen: (open) =>
|
||||
set((state) => ({
|
||||
isOpen: open,
|
||||
target: open ? state.target : null,
|
||||
})),
|
||||
}));
|
||||
Reference in New Issue
Block a user