Skip to content

Commit 5c775da

Browse files
Merge pull request #45 from ItsukiKigoshi/39-feat-google-drive-sync
Add Download CSV Feature
2 parents 3d8d6ea + 6c03806 commit 5c775da

File tree

5 files changed

+44
-22
lines changed

5 files changed

+44
-22
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ next-env.d.ts
4141
**/public/workbox-*.js
4242
**/public/workbox-*.js.map
4343

44-
.env
44+
.env
45+
yarn.lock

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
"@tiptap/extension-link": "^2.1.12",
2929
"@tiptap/react": "^2.1.12",
3030
"@tiptap/starter-kit": "^2.1.12",
31+
"@types/react-csv": "^1.1.10",
3132
"@vercel/analytics": "^1.1.2",
3233
"dayjs": "^1.11.10",
3334
"embla-carousel-react": "^7.1.0",
3435
"next": "14.0.3",
3536
"next-pwa": "^5.6.0",
3637
"react": "^18",
38+
"react-csv": "^2.2.2",
3739
"react-dom": "^18"
3840
},
3941
"devDependencies": {

src/app/page.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use client";
2-
import { AppShell, Button, Flex, em } from "@mantine/core";
2+
import { AppShell, Button, Flex, Group, Text, em } from "@mantine/core";
33
import { useDisclosure, useMediaQuery, useToggle } from "@mantine/hooks";
4-
import { IconCalendar, IconList } from "@tabler/icons-react";
4+
import { IconCalendar, IconDownload, IconList } from "@tabler/icons-react";
55
import { useEffect, useState } from "react";
6+
import { CSVLink } from "react-csv";
67
import { Header } from "../components/Header";
78
import { Navbar } from "../components/Navbar";
89
import { Timetable } from "../components/Timetable";
@@ -207,7 +208,6 @@ export default function Page() {
207208
</AppShell.Main>
208209
<AppShell.Footer
209210
withBorder={false}
210-
hiddenFrom="sm"
211211
h="60px"
212212
style={{ background: "rgba(0,0,0,0)" }}
213213
>
@@ -220,6 +220,17 @@ export default function Page() {
220220
>
221221
Search
222222
</Button> */}
223+
<CSVLink
224+
data={courses}
225+
filename={`courses-${new Date().toISOString().slice(0, 10)}.csv`}
226+
>
227+
<Button color="gray" size="lg">
228+
<Group>
229+
<IconDownload />
230+
<Text visibleFrom="sm">Download CSV</Text>
231+
</Group>
232+
</Button>
233+
</CSVLink>
223234
<Button
224235
hiddenFrom="sm"
225236
size="lg"

src/components/AddCourse/index.tsx

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Course } from "@/src/type/Types";
2-
import { Button, Flex } from "@mantine/core";
2+
import { Button, Group, TextInput } from "@mantine/core";
33
import { useDisclosure } from "@mantine/hooks";
4-
import { IconPlus } from "@tabler/icons-react";
4+
import { IconClipboard, IconPlus } from "@tabler/icons-react";
55
import { useEffect, useState } from "react";
66
import ModalCourseEditor from "../ModalCourseEditor";
77

@@ -157,32 +157,22 @@ export default function AddCourse(props: {
157157
modalCourseEditorOpened={modalCourseEditorOpened}
158158
editorClose={editorClose}
159159
/>
160-
<Flex justify="center" gap="xs">
161-
<Button
162-
leftSection={<IconPlus />}
163-
color="gray"
164-
onClick={editorOpen}
165-
w="100%"
166-
>
160+
<Group grow>
161+
<Button leftSection={<IconPlus />} color="gray" onClick={editorOpen}>
167162
Add Manually
168163
</Button>
169164

170-
{/* <TextInput
165+
<TextInput
171166
m="0"
172167
placeholder="Paste it!"
173-
leftSection={
174-
<IconClipboard
175-
style={{ width: rem(12), height: rem(12) }}
176-
stroke={1.5}
177-
/>
178-
}
168+
leftSection={<IconClipboard />}
179169
styles={{ section: { pointerEvents: "none" } }}
180170
value={query}
181171
error={errorMessage}
182172
onChange={(e) => setQuery(e.currentTarget.value)}
183173
onSubmit={handleSubmit}
184-
/>*/}
185-
</Flex>
174+
/>
175+
</Group>
186176
</>
187177
);
188178
}

yarn.lock

+18
Original file line numberDiff line numberDiff line change
@@ -4820,6 +4820,15 @@ __metadata:
48204820
languageName: node
48214821
linkType: hard
48224822

4823+
"@types/react-csv@npm:^1.1.10":
4824+
version: 1.1.10
4825+
resolution: "@types/react-csv@npm:1.1.10"
4826+
dependencies:
4827+
"@types/react": "npm:*"
4828+
checksum: 10c0/58d300aacccc70c67d2df538726983b4483f3b446db67687baa0026bd4d562cbb956a47eab49516bbe22b9bf8e9b92d1e28f608361a77b2ffa36825bd9c72295
4829+
languageName: node
4830+
linkType: hard
4831+
48234832
"@types/react-dom@npm:^18":
48244833
version: 18.2.18
48254834
resolution: "@types/react-dom@npm:18.2.18"
@@ -6445,6 +6454,7 @@ __metadata:
64456454
"@types/jest": "npm:^29.5.9"
64466455
"@types/node": "npm:^20"
64476456
"@types/react": "npm:^18"
6457+
"@types/react-csv": "npm:^1.1.10"
64486458
"@types/react-dom": "npm:^18"
64496459
"@vercel/analytics": "npm:^1.1.2"
64506460
dayjs: "npm:^1.11.10"
@@ -6458,6 +6468,7 @@ __metadata:
64586468
postcss-preset-mantine: "npm:^1.11.0"
64596469
postcss-simple-vars: "npm:^7.0.1"
64606470
react: "npm:^18"
6471+
react-csv: "npm:^2.2.2"
64616472
react-dom: "npm:^18"
64626473
storybook: "npm:^7.5.3"
64636474
storybook-addon-mantine: "npm:^3.0.1"
@@ -12955,6 +12966,13 @@ __metadata:
1295512966
languageName: node
1295612967
linkType: hard
1295712968

12969+
"react-csv@npm:^2.2.2":
12970+
version: 2.2.2
12971+
resolution: "react-csv@npm:2.2.2"
12972+
checksum: 10c0/287e7ba2085a32a0e65d7a19b9e063e43f06f75ab6ebc18bb52b518007a1d6ec5f5ce33fc7c4e290e3ea41cfb251657b6e62aadadc8d7ffcef7e53d43bf3eb69
12973+
languageName: node
12974+
linkType: hard
12975+
1295812976
"react-docgen-typescript@npm:^2.2.2":
1295912977
version: 2.2.2
1296012978
resolution: "react-docgen-typescript@npm:2.2.2"

0 commit comments

Comments
 (0)