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