Skip to content

Commit

Permalink
reset stored user on error in adding to cart
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelSiidorow committed Jan 25, 2024
1 parent ea49e14 commit daea8af
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions web/context/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const AppProvider: FC<Props> = ({ children }) => {
mutate: mutateOrder,
error,
} = useSWR<Order>(orderUid ? `/api/orders/${orderUid}` : null, fetcher);
console.log("order", order);
const customer = useMemo(
() => order?.attributes?.customer?.data || appContextDefault.customer,
[order],
Expand All @@ -90,8 +89,6 @@ const AppProvider: FC<Props> = ({ children }) => {
() => order?.attributes?.items?.data || appContextDefault.items,
[order],
);
console.log("customer", customer);
console.log("items", items);
const reset = useCallback(() => {
localStorage.removeItem("orderUid");
setOrderUid("");
Expand Down Expand Up @@ -139,6 +136,7 @@ const AppProvider: FC<Props> = ({ children }) => {
mutateOrder(newOrder);
} catch (error) {
// Error in deleting an item
reset();
}
};

Expand All @@ -158,6 +156,7 @@ const AppProvider: FC<Props> = ({ children }) => {
mutateOrder(newOrder);
} catch (error) {
// Error in adding an item
reset();
}
};
const refreshFields = async () => {
Expand Down

0 comments on commit daea8af

Please sign in to comment.