aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-09-05 18:48:59 +0100
committerGravatar Joe Banks <[email protected]>2024-09-05 18:48:59 +0100
commit99fe717a0a68499c6a91b5f48f9478c4d7b91497 (patch)
tree85af6a40133a7e96442a1fb19c50b26b6404c120
parentAdd item to cart slice on button press in StoreItem (diff)
Handle 401 and 403 on store page
-rw-r--r--thallium-frontend/src/pages/StorePage.tsx8
1 files changed, 7 insertions, 1 deletions
diff --git a/thallium-frontend/src/pages/StorePage.tsx b/thallium-frontend/src/pages/StorePage.tsx
index 0ebc228..3e8df92 100644
--- a/thallium-frontend/src/pages/StorePage.tsx
+++ b/thallium-frontend/src/pages/StorePage.tsx
@@ -3,12 +3,13 @@ import { RootState } from "../store";
import { useEffect, useState } from "react";
import { Template, getTemplates } from "../api/templates";
-import { APIMissingTokenError } from "../api/client";
+import { APIError, APIMissingTokenError } from "../api/client";
import StoreItem from "../components/StoreItem";
import styled from "styled-components";
import { Link } from "react-router-dom";
import LoadingBar from "../components/LoadingBar";
+import CartStatus from "../components/CartStatus";
const StoreGrid = styled.div`
@@ -35,6 +36,10 @@ const StorePage = () => {
setLoading(false);
if (err instanceof APIMissingTokenError) {
setPermissionDenied(true);
+ } else if (err instanceof APIError) {
+ if ([401, 403].includes(err.status)) {
+ setPermissionDenied(true);
+ }
}
});
}, [voucherToken]);
@@ -42,6 +47,7 @@ const StorePage = () => {
return (
<>
<h1>Giveaway Store</h1>
+ {!(loading || permissionDenied) && <CartStatus />}
{loading && <LoadingBar />}
<StoreGrid>
{storeItems?.map((item) => (