Skip to content

Commit 149bdab

Browse files
Some error and exeption handling in shop (#1993)
2 parents c3f1b2e + a0a2cf6 commit 149bdab

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

frontend/src/pages/janus/shop.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useQuery } from "@apollo/client";
2-
import { Grid, Typography } from "@mui/material";
2+
import { CircularProgress, Grid, Typography } from "@mui/material";
33

44
import { ShopItem } from "@/components/pages/Janus/Shop/ShopItem";
55
import { Template } from "@/components/pages/Janus/Template";
@@ -8,8 +8,35 @@ import { Layout } from "@/layouts/Layout";
88
import { NextPageWithLayout } from "@/lib/next";
99

1010
const ShopPage: NextPageWithLayout = () => {
11-
const { data } = useQuery(ProductsDocument);
11+
const { loading, error, data } = useQuery(ProductsDocument);
1212

13+
if (loading) {
14+
return (
15+
<Template title="Janus Nettbutikk" description="">
16+
<CircularProgress />
17+
</Template>
18+
);
19+
}
20+
if (error) {
21+
return (
22+
<Template title="Janus Nettbutikk" description="">
23+
<Typography variant="body1" gutterBottom>
24+
Feil ved lasting av produkter. Vennligst prøv igjen senere. Hvis problemet vedvarer, kontakt
25+
26+
</Typography>
27+
</Template>
28+
);
29+
}
30+
if (data === undefined) {
31+
return (
32+
<Template title="Janus Nettbutikk" description="">
33+
<Typography variant="body1" gutterBottom>
34+
Fant ingen produkter. Vennligst sjekk at du er innlogget og prøv igjen. Hvis problemet vedvarer, kontakt
35+
36+
</Typography>
37+
</Template>
38+
);
39+
}
1340
return (
1441
<Template title="Janus Nettbutikk" description="">
1542
<Typography variant="h3" gutterBottom>

0 commit comments

Comments
 (0)