Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 2092b2e

Browse files
Merge pull request #74 from debater-coder/73-remove-saved-barcodes
feat: remove saved barcodes
2 parents c779da2 + 8ce0045 commit 2092b2e

File tree

3 files changed

+0
-167
lines changed

3 files changed

+0
-167
lines changed

src/routes/Main/Barcodes/AddBarcodeForm.tsx

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/routes/Main/Barcodes/Barcodes.tsx

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ import {
55
Heading,
66
useColorModeValue,
77
} from "@chakra-ui/react";
8-
import { useState } from "react";
9-
import { get, update } from "idb-keyval";
10-
import { Barcode as BarcodeIcon } from "phosphor-react";
11-
import SavedBarcode from "./SavedBarcode";
128
import YourBarcode from "./YourBarcode";
13-
import { AddBarcodeForm } from "./AddBarcodeForm";
14-
import Empty from "../../../components/Empty";
159
import { createLoader } from "../../../utils/createLoader";
1610
import { profileQuery, useProfile } from "../../../services/sbhsApi/useProfile";
1711
import { useLoaderData } from "react-router-dom";
@@ -25,43 +19,10 @@ export type Barcode = {
2519
export const loader = createLoader({ queryHook: profileQuery });
2620

2721
export default () => {
28-
const [barcodes, setBarcodes] = useState<Barcode[]>([]);
29-
3022
const { data, isLoading } = useProfile({
3123
initialData: (useLoaderData() as [ApiProfile])[0],
3224
});
3325

34-
const addBarcode = async (name: string, value: string) => {
35-
setBarcodes((barcodes) => [...barcodes, { name, value }]);
36-
await update("barcodes", (barcodes) => {
37-
if (!barcodes) {
38-
return [
39-
{
40-
name,
41-
value,
42-
},
43-
];
44-
}
45-
return [...barcodes, { name, value }];
46-
});
47-
};
48-
49-
const getBarcodes = async () => {
50-
const newBarcodes = await get("barcodes");
51-
setBarcodes(newBarcodes ?? []);
52-
};
53-
54-
const deleteBarcode = async (name: string) => {
55-
setBarcodes((barcodes) =>
56-
barcodes.filter((barcode) => barcode.name !== name)
57-
);
58-
await update("barcodes", (barcodes: Barcode[]) =>
59-
barcodes.filter((barcode) => barcode.name !== name)
60-
);
61-
};
62-
63-
getBarcodes();
64-
6526
return (
6627
<Flex direction={"column"} gap={3} align="center" textAlign={"center"}>
6728
<Flex align="center" gap={3}>
@@ -81,63 +42,6 @@ export default () => {
8142
</Tooltip>
8243
</Flex>
8344
<YourBarcode {...{ data, isLoading }} />
84-
<Flex align="center" mt={6}>
85-
<Heading fontFamily={"Poppins, sans-serif"} fontSize="xl" mr={3}>
86-
Saved barcodes
87-
</Heading>
88-
<Tooltip
89-
label={
90-
"You can save your own barcodes here if you need to create a barcode with a custom value. Enter the name and value, then click the 'Add Barcode' button to save it. For a student barcode, you enter the student ID as the value."
91-
}
92-
closeOnClick={false}
93-
>
94-
<Icon
95-
boxSize={7}
96-
color={useColorModeValue("primary.500", "primary.300")}
97-
/>
98-
</Tooltip>
99-
</Flex>
100-
<Flex
101-
direction={"column"}
102-
align="center"
103-
gap={3}
104-
mb={{ base: 80, md: 60 }}
105-
>
106-
{barcodes.length > 0 ? (
107-
barcodes.map(({ name, value }) => (
108-
<SavedBarcode
109-
name={name}
110-
value={value}
111-
key={name}
112-
onDelete={deleteBarcode}
113-
/>
114-
))
115-
) : (
116-
<Empty
117-
icon={BarcodeIcon}
118-
colour="primary.500"
119-
heading="You have no saved barcodes."
120-
size="xl"
121-
text={
122-
<>
123-
Type in a name for your barcode and its value, then click the{" "}
124-
<b>Add Barcode</b> button to save it.
125-
</>
126-
}
127-
/>
128-
)}
129-
</Flex>
130-
<Flex
131-
direction={"column"}
132-
position={"fixed"}
133-
bottom={{ base: 20, md: 0 }}
134-
bg={useColorModeValue("gray.200", "gray.700")}
135-
p={4}
136-
roundedTop={10}
137-
shadow={"outline"}
138-
>
139-
<AddBarcodeForm addBarcode={addBarcode} barcodes={barcodes} />
140-
</Flex>
14145
</Flex>
14246
);
14347
};

src/routes/Main/Home/Home.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export default function Home() {
5555
date === "initial" ? undefined : date
5656
);
5757

58-
console.log(data);
59-
6058
const periods: TimetablPeriod[] =
6159
data?.periods ??
6260
Array(7).fill({

0 commit comments

Comments
 (0)