Update gift-context.tsx

This commit is contained in:
2025-03-16 16:35:35 +01:00
parent 88c9e634de
commit f6ac22731d

View File

@@ -48,29 +48,34 @@ interface GiftContextState {
refetchCategories: (eventId: string) => Promise<any>; refetchCategories: (eventId: string) => Promise<any>;
fetchCategoryById: (id: string, eventId?: string) => void; fetchCategoryById: (id: string, eventId?: string) => void;
createCategory: (data: GiftCategoryCreate) => Promise<GiftCategory | undefined>; createCategory: (
data: GiftCategoryCreate,
) => Promise<GiftCategory | undefined>;
updateCategory: ( updateCategory: (
id: string, id: string,
data: GiftCategoryUpdate, data: GiftCategoryUpdate,
eventId?: string eventId?: string,
) => Promise<GiftCategory | undefined>;
deleteCategory: (
id: string,
eventId?: string,
) => Promise<GiftCategory | undefined>; ) => Promise<GiftCategory | undefined>;
deleteCategory: (id: string, eventId?: string) => Promise<GiftCategory | undefined>;
associateCategoryWithEvent: ( associateCategoryWithEvent: (
categoryId: string, categoryId: string,
eventId: string, eventId: string,
displayOrder?: number, displayOrder?: number,
isVisible?: boolean isVisible?: boolean,
) => Promise<GiftCategory | undefined>; ) => Promise<GiftCategory | undefined>;
updateCategoryEventSettings: ( updateCategoryEventSettings: (
categoryId: string, categoryId: string,
eventId: string, eventId: string,
displayOrder?: number, displayOrder?: number,
isVisible?: boolean isVisible?: boolean,
) => Promise<GiftCategory | undefined>; ) => Promise<GiftCategory | undefined>;
getEventsForCategory: (categoryId: string) => Promise<any>; getEventsForCategory: (categoryId: string) => Promise<any>;
reorderGiftsInCategory: ( reorderGiftsInCategory: (
categoryId: string, categoryId: string,
giftIds: string[] giftIds: string[],
) => Promise<GiftCategory | undefined>; ) => Promise<GiftCategory | undefined>;
// Gift Items // Gift Items
@@ -84,21 +89,21 @@ interface GiftContextState {
createItem: (data: GiftItemCreate) => Promise<GiftItem | undefined>; createItem: (data: GiftItemCreate) => Promise<GiftItem | undefined>;
updateItem: ( updateItem: (
id: string, id: string,
data: GiftItemUpdate data: GiftItemUpdate,
) => Promise<GiftItem | undefined>; ) => Promise<GiftItem | undefined>;
deleteItem: (id: string) => Promise<GiftItem | undefined>; deleteItem: (id: string) => Promise<GiftItem | undefined>;
updateItemStatus: ( updateItemStatus: (
id: string, id: string,
status: GiftStatus status: GiftStatus,
) => Promise<GiftItem | undefined>; ) => Promise<GiftItem | undefined>;
reserveItem: ( reserveItem: (
id: string, id: string,
guestId: string, guestId: string,
quantity?: number quantity?: number,
) => Promise<GiftItem | undefined>; ) => Promise<GiftItem | undefined>;
cancelReservation: ( cancelReservation: (
id: string, id: string,
guestId: string guestId: string,
) => Promise<GiftItem | undefined>; ) => Promise<GiftItem | undefined>;
// Gift Purchases // Gift Purchases
@@ -109,9 +114,13 @@ interface GiftContextState {
refetchPurchases: (giftId?: string, guestId?: string) => Promise<any>; refetchPurchases: (giftId?: string, guestId?: string) => Promise<any>;
fetchPurchaseById: (id: string) => void; fetchPurchaseById: (id: string) => void;
createPurchase: (data: GiftPurchaseCreate) => Promise<GiftPurchase | undefined>; createPurchase: (
data: GiftPurchaseCreate,
) => Promise<GiftPurchase | undefined>;
fetchPurchasesByGift: (giftId: string) => Promise<GiftPurchase[] | undefined>; fetchPurchasesByGift: (giftId: string) => Promise<GiftPurchase[] | undefined>;
fetchPurchasesByGuest: (guestId: string) => Promise<GiftPurchase[] | undefined>; fetchPurchasesByGuest: (
guestId: string,
) => Promise<GiftPurchase[] | undefined>;
// Current selections // Current selections
currentCategoryId: string | null; currentCategoryId: string | null;
@@ -242,10 +251,16 @@ interface GiftProviderProps {
// Gift Provider Component // Gift Provider Component
export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => { export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [currentCategoryId, setCurrentCategoryId] = React.useState<string | null>(null); const [currentCategoryId, setCurrentCategoryId] = React.useState<
string | null
>(null);
const [currentItemId, setCurrentItemId] = React.useState<string | null>(null); const [currentItemId, setCurrentItemId] = React.useState<string | null>(null);
const [currentPurchaseId, setCurrentPurchaseId] = React.useState<string | null>(null); const [currentPurchaseId, setCurrentPurchaseId] = React.useState<
const [currentEventId, setCurrentEventId] = React.useState<string | null>(null); string | null
>(null);
const [currentEventId, setCurrentEventId] = React.useState<string | null>(
null,
);
// Fetch all categories for an event // Fetch all categories for an event
const { const {
@@ -258,7 +273,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
queryFn: () => queryFn: () =>
currentEventId currentEventId
? readGiftCategories({ ? readGiftCategories({
path: { event_id: currentEventId } path: { event_id: currentEventId },
}).then((res) => res.data) }).then((res) => res.data)
: Promise.resolve(undefined), : Promise.resolve(undefined),
enabled: !!currentEventId, enabled: !!currentEventId,
@@ -280,9 +295,9 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
currentCategoryId currentCategoryId
? readGiftCategory({ ? readGiftCategory({
path: { path: {
category_id: currentCategoryId category_id: currentCategoryId,
}, },
query: currentEventId ? { event_id: currentEventId } : undefined query: currentEventId ? { event_id: currentEventId } : undefined,
}).then((res) => res.data) }).then((res) => res.data)
: Promise.resolve(undefined), : Promise.resolve(undefined),
enabled: !!currentCategoryId, enabled: !!currentCategoryId,
@@ -298,10 +313,15 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
// Create Category Mutation // Create Category Mutation
const createCategoryMutation = useMutation({ const createCategoryMutation = useMutation({
mutationFn: (data: GiftCategoryCreate) => mutationFn: (data: GiftCategoryCreate) =>
createGiftCategory({ body: data }).then((res) => res.data), createGiftCategory({
body: data,
query: { event_id: currentEventId || "" },
}).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftCategories", currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftCategories", currentEventId],
});
} }
}, },
}); });
@@ -311,7 +331,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
mutationFn: ({ mutationFn: ({
id, id,
data, data,
eventId eventId,
}: { }: {
id: string; id: string;
data: GiftCategoryUpdate; data: GiftCategoryUpdate;
@@ -320,14 +340,18 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
updateGiftCategory({ updateGiftCategory({
path: { category_id: id }, path: { category_id: id },
body: data, body: data,
query: eventId ? { event_id: eventId } : undefined query: eventId ? { event_id: eventId } : undefined,
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftCategories", currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftCategories", currentEventId],
});
} }
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftCategory", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftCategory", currentCategoryId],
});
} }
}, },
}); });
@@ -337,11 +361,13 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
mutationFn: ({ id, eventId }: { id: string; eventId?: string }) => mutationFn: ({ id, eventId }: { id: string; eventId?: string }) =>
deleteGiftCategory({ deleteGiftCategory({
path: { category_id: id }, path: { category_id: id },
query: eventId ? { event_id: eventId } : undefined query: eventId ? { event_id: eventId } : undefined,
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftCategories", currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftCategories", currentEventId],
});
} }
}, },
}); });
@@ -359,13 +385,16 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
if (currentCategoryId) { if (currentCategoryId) {
query.category_id = currentCategoryId; query.category_id = currentCategoryId;
} }
if (currentEventId) { // We don't need to add event_id to query since it's part of the path
query.event_id = currentEventId;
if (!currentEventId) {
return Promise.resolve(undefined);
} }
return Object.keys(query).length > 0 return readGiftItems({
? readGiftItems({ query }).then((res) => res.data) path: { event_id: currentEventId },
: Promise.resolve(undefined); query,
}).then((res) => res.data);
}, },
enabled: !!(currentCategoryId || currentEventId), enabled: !!(currentCategoryId || currentEventId),
}); });
@@ -391,8 +420,8 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
currentItemId currentItemId
? readGiftItem({ ? readGiftItem({
path: { path: {
gift_id: currentItemId item_id: currentItemId,
} },
}).then((res) => res.data) }).then((res) => res.data)
: Promise.resolve(undefined), : Promise.resolve(undefined),
enabled: !!currentItemId, enabled: !!currentItemId,
@@ -408,36 +437,40 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
createGiftItem({ body: data }).then((res) => res.data), createGiftItem({ body: data }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", currentCategoryId],
});
} }
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", null, currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", null, currentEventId],
});
} }
}, },
}); });
// Update Item Mutation // Update Item Mutation
const updateItemMutation = useMutation({ const updateItemMutation = useMutation({
mutationFn: ({ mutationFn: ({ id, data }: { id: string; data: GiftItemUpdate }) =>
id,
data
}: {
id: string;
data: GiftItemUpdate;
}) =>
updateGiftItem({ updateGiftItem({
path: { gift_id: id }, path: { item_id: id },
body: data body: data,
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", currentCategoryId],
});
} }
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", null, currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", null, currentEventId],
});
} }
if (currentItemId) { if (currentItemId) {
queryClient.invalidateQueries({ queryKey: ["giftItem", currentItemId] }); queryClient.invalidateQueries({
queryKey: ["giftItem", currentItemId],
});
} }
}, },
}); });
@@ -446,40 +479,44 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
const deleteItemMutation = useMutation({ const deleteItemMutation = useMutation({
mutationFn: (id: string) => mutationFn: (id: string) =>
deleteGiftItem({ deleteGiftItem({
path: { gift_id: id } path: { item_id: id },
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", currentCategoryId],
});
} }
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", null, currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", null, currentEventId],
});
} }
}, },
}); });
// Update Item Status Mutation // Update Item Status Mutation
const updateItemStatusMutation = useMutation({ const updateItemStatusMutation = useMutation({
mutationFn: ({ mutationFn: ({ id, status }: { id: string; status: GiftStatus }) =>
id,
status
}: {
id: string;
status: GiftStatus;
}) =>
updateGiftItemStatus({ updateGiftItemStatus({
path: { gift_id: id }, path: { item_id: id },
body: { status } query: { status },
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", currentCategoryId],
});
} }
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", null, currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", null, currentEventId],
});
} }
if (currentItemId) { if (currentItemId) {
queryClient.invalidateQueries({ queryKey: ["giftItem", currentItemId] }); queryClient.invalidateQueries({
queryKey: ["giftItem", currentItemId],
});
} }
}, },
}); });
@@ -489,56 +526,64 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
mutationFn: ({ mutationFn: ({
id, id,
guestId, guestId,
quantity quantity,
}: { }: {
id: string; id: string;
guestId: string; guestId: string;
quantity?: number; quantity?: number;
}) => }) =>
reserveGiftItem({ reserveGiftItem({
path: { gift_id: id }, path: { item_id: id },
body: { query: {
guest_id: guestId, guest_id: guestId,
quantity quantity,
} },
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", currentCategoryId],
});
} }
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", null, currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", null, currentEventId],
});
} }
if (currentItemId) { if (currentItemId) {
queryClient.invalidateQueries({ queryKey: ["giftItem", currentItemId] }); queryClient.invalidateQueries({
queryKey: ["giftItem", currentItemId],
});
} }
}, },
}); });
// Cancel Reservation Mutation // Cancel Reservation Mutation
const cancelReservationMutation = useMutation({ const cancelReservationMutation = useMutation({
mutationFn: ({ mutationFn: ({ id, guestId }: { id: string; guestId: string }) =>
id,
guestId
}: {
id: string;
guestId: string;
}) =>
cancelGiftReservation({ cancelGiftReservation({
path: { path: {
gift_id: id, item_id: id,
guest_id: guestId },
} query: {
guest_id: guestId,
},
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", currentCategoryId],
});
} }
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftItems", null, currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftItems", null, currentEventId],
});
} }
if (currentItemId) { if (currentItemId) {
queryClient.invalidateQueries({ queryKey: ["giftItem", currentItemId] }); queryClient.invalidateQueries({
queryKey: ["giftItem", currentItemId],
});
} }
}, },
}); });
@@ -549,7 +594,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
categoryId, categoryId,
eventId, eventId,
displayOrder, displayOrder,
isVisible isVisible,
}: { }: {
categoryId: string; categoryId: string;
eventId: string; eventId: string;
@@ -559,16 +604,18 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
associateCategoryWithEvent({ associateCategoryWithEvent({
path: { path: {
category_id: categoryId, category_id: categoryId,
event_id: eventId event_id: eventId,
}, },
body: { query: {
display_order: displayOrder, display_order: displayOrder,
is_visible: isVisible is_visible: isVisible,
} },
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftCategories", currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftCategories", currentEventId],
});
} }
}, },
}); });
@@ -579,7 +626,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
categoryId, categoryId,
eventId, eventId,
displayOrder, displayOrder,
isVisible isVisible,
}: { }: {
categoryId: string; categoryId: string;
eventId: string; eventId: string;
@@ -589,19 +636,23 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
updateCategoryEventSettings({ updateCategoryEventSettings({
path: { path: {
category_id: categoryId, category_id: categoryId,
event_id: eventId event_id: eventId,
}, },
body: { query: {
display_order: displayOrder, display_order: displayOrder,
is_visible: isVisible is_visible: isVisible,
} },
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftCategories", currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftCategories", currentEventId],
});
} }
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftCategory", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftCategory", currentCategoryId],
});
} }
}, },
}); });
@@ -609,7 +660,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
// Get Events For Category Query // Get Events For Category Query
const getEventsForCategoryQuery = async (categoryId: string) => { const getEventsForCategoryQuery = async (categoryId: string) => {
return getEventsForCategory({ return getEventsForCategory({
path: { category_id: categoryId } path: { category_id: categoryId },
}).then((res) => res.data); }).then((res) => res.data);
}; };
@@ -617,21 +668,25 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
const reorderGiftsInCategoryMutation = useMutation({ const reorderGiftsInCategoryMutation = useMutation({
mutationFn: ({ mutationFn: ({
categoryId, categoryId,
giftIds giftIds,
}: { }: {
categoryId: string; categoryId: string;
giftIds: string[]; giftIds: string[];
}) => }) =>
reorderGiftsInCategory({ reorderGiftsInCategory({
path: { category_id: categoryId }, path: { category_id: categoryId },
body: { gift_ids: giftIds } body: giftIds.reduce((acc, id, index) => ({ ...acc, [id]: index }), {}),
}).then((res) => res.data), }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentCategoryId) { if (currentCategoryId) {
queryClient.invalidateQueries({ queryKey: ["giftCategory", currentCategoryId] }); queryClient.invalidateQueries({
queryKey: ["giftCategory", currentCategoryId],
});
} }
if (currentEventId) { if (currentEventId) {
queryClient.invalidateQueries({ queryKey: ["giftCategories", currentEventId] }); queryClient.invalidateQueries({
queryKey: ["giftCategories", currentEventId],
});
} }
}, },
}); });
@@ -647,7 +702,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
queryFn: () => queryFn: () =>
currentItemId currentItemId
? readGiftPurchasesByGift({ ? readGiftPurchasesByGift({
path: { gift_id: currentItemId } path: { gift_id: currentItemId },
}).then((res) => res.data) }).then((res) => res.data)
: Promise.resolve(undefined), : Promise.resolve(undefined),
enabled: !!currentItemId, enabled: !!currentItemId,
@@ -670,7 +725,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
queryFn: () => queryFn: () =>
currentPurchaseId currentPurchaseId
? readGiftPurchase({ ? readGiftPurchase({
path: { purchase_id: currentPurchaseId } path: { purchase_id: currentPurchaseId },
}).then((res) => res.data) }).then((res) => res.data)
: Promise.resolve(undefined), : Promise.resolve(undefined),
enabled: !!currentPurchaseId, enabled: !!currentPurchaseId,
@@ -686,8 +741,12 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
createGiftPurchase({ body: data }).then((res) => res.data), createGiftPurchase({ body: data }).then((res) => res.data),
onSuccess: () => { onSuccess: () => {
if (currentItemId) { if (currentItemId) {
queryClient.invalidateQueries({ queryKey: ["giftPurchases", currentItemId] }); queryClient.invalidateQueries({
queryClient.invalidateQueries({ queryKey: ["giftItem", currentItemId] }); queryKey: ["giftPurchases", currentItemId],
});
queryClient.invalidateQueries({
queryKey: ["giftItem", currentItemId],
});
} }
}, },
}); });
@@ -695,14 +754,14 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
// Fetch Purchases By Gift // Fetch Purchases By Gift
const fetchPurchasesByGiftQuery = async (giftId: string) => { const fetchPurchasesByGiftQuery = async (giftId: string) => {
return readGiftPurchasesByGift({ return readGiftPurchasesByGift({
path: { gift_id: giftId } path: { gift_id: giftId },
}).then((res) => res.data); }).then((res) => res.data);
}; };
// Fetch Purchases By Guest // Fetch Purchases By Guest
const fetchPurchasesByGuestQuery = async (guestId: string) => { const fetchPurchasesByGuestQuery = async (guestId: string) => {
return readGiftPurchasesByGuest({ return readGiftPurchasesByGuest({
path: { guest_id: guestId } path: { guest_id: guestId },
}).then((res) => res.data); }).then((res) => res.data);
}; };
@@ -730,8 +789,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
fetchItemById, fetchItemById,
createItem: createItemMutation.mutateAsync, createItem: createItemMutation.mutateAsync,
updateItem: (id, data) => updateItem: (id, data) => updateItemMutation.mutateAsync({ id, data }),
updateItemMutation.mutateAsync({ id, data }),
deleteItem: deleteItemMutation.mutateAsync, deleteItem: deleteItemMutation.mutateAsync,
updateItemStatus: (id, status) => updateItemStatus: (id, status) =>
updateItemStatusMutation.mutateAsync({ id, status }), updateItemStatusMutation.mutateAsync({ id, status }),
@@ -741,10 +799,30 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
cancelReservationMutation.mutateAsync({ id, guestId }), cancelReservationMutation.mutateAsync({ id, guestId }),
// Gift Categories additional methods // Gift Categories additional methods
associateCategoryWithEvent: (categoryId, eventId, displayOrder, isVisible) => associateCategoryWithEvent: (
associateCategoryWithEventMutation.mutateAsync({ categoryId, eventId, displayOrder, isVisible }), categoryId,
updateCategoryEventSettings: (categoryId, eventId, displayOrder, isVisible) => eventId,
updateCategoryEventSettingsMutation.mutateAsync({ categoryId, eventId, displayOrder, isVisible }), displayOrder,
isVisible,
) =>
associateCategoryWithEventMutation.mutateAsync({
categoryId,
eventId,
displayOrder,
isVisible,
}),
updateCategoryEventSettings: (
categoryId,
eventId,
displayOrder,
isVisible,
) =>
updateCategoryEventSettingsMutation.mutateAsync({
categoryId,
eventId,
displayOrder,
isVisible,
}),
getEventsForCategory: getEventsForCategoryQuery, getEventsForCategory: getEventsForCategoryQuery,
reorderGiftsInCategory: (categoryId, giftIds) => reorderGiftsInCategory: (categoryId, giftIds) =>
reorderGiftsInCategoryMutation.mutateAsync({ categoryId, giftIds }), reorderGiftsInCategoryMutation.mutateAsync({ categoryId, giftIds }),
@@ -771,7 +849,12 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
currentEventId, currentEventId,
setCurrentEventId, setCurrentEventId,
error: (categoriesError || categoryError || itemsError || itemError || purchasesError || purchaseError) as Error | null, error: (categoriesError ||
categoryError ||
itemsError ||
itemError ||
purchasesError ||
purchaseError) as Error | null,
}; };
return ( return (