Fix minor bugs in gift-context.tsx

This commit is contained in:
2025-03-16 17:47:56 +01:00
parent 97a9e1588f
commit e2c6c64fe7

View File

@@ -275,7 +275,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
? readGiftCategories({
path: { event_id: currentEventId },
}).then((res) => res.data)
: Promise.resolve(undefined),
: Promise.resolve([]),
enabled: !!currentEventId,
});
@@ -385,10 +385,9 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
if (currentCategoryId) {
query.category_id = currentCategoryId;
}
// We don't need to add event_id to query since it's part of the path
if (!currentEventId) {
return Promise.resolve(undefined);
return Promise.resolve([]);
}
return readGiftItems({
@@ -396,7 +395,7 @@ export const GiftProvider: React.FC<GiftProviderProps> = ({ children }) => {
query,
}).then((res) => res.data);
},
enabled: !!(currentCategoryId || currentEventId),
enabled: !!currentEventId,
});
const refetchItems = async (categoryId?: string, eventId?: string) => {