From 9e091b793aed7768c51fbc8d03edbd4a81b4eed8 Mon Sep 17 00:00:00 2001 From: Angle Date: Wed, 23 Oct 2024 03:44:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8B=8D=E8=B3=A3=E7=9A=84TableView=EF=BC=8C=E4=BD=86=E6=AA=94?= =?UTF-8?q?=E5=90=8D=E6=9A=AB=E6=99=82=E9=82=84=E6=98=AFadd=5Fsell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- src/routeTree.gen.ts | 25 +++++++ src/routes/sales/add_sell.tsx | 132 ++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 src/routes/sales/add_sell.tsx diff --git a/.env b/.env index 2bb19b6..b4769f9 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ VITE_SUPABASE_URL=http://127.0.0.1:54321 -VITE_SUPABASE_ANON_KEY= +VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0 diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index e4b276f..0356e67 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -18,6 +18,7 @@ import { Route as MapIndexImport } from './routes/map/index' import { Route as EventsIndexImport } from './routes/events/index' import { Route as DinnerIndexImport } from './routes/dinner/index' import { Route as CalendarIndexImport } from './routes/calendar/index' +import { Route as SalesAddsellImport } from './routes/sales/add_sell' import { Route as HomeInfoCardImport } from './routes/home/infoCard' import { Route as EventsCreateImport } from './routes/events/create' import { Route as EventsEventIdImport } from './routes/events/$eventId' @@ -59,6 +60,11 @@ const CalendarIndexRoute = CalendarIndexImport.update({ getParentRoute: () => rootRoute, } as any) +const SalesAddsellRoute = SalesAddsellImport.update({ + path: '/sales/add_sell', + getParentRoute: () => rootRoute, +} as any) + const HomeInfoCardRoute = HomeInfoCardImport.update({ path: '/home/infoCard', getParentRoute: () => rootRoute, @@ -113,6 +119,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof HomeInfoCardImport parentRoute: typeof rootRoute } + '/sales/add_sell': { + id: '/sales/add_sell' + path: '/sales/add_sell' + fullPath: '/sales/add_sell' + preLoaderRoute: typeof SalesAddsellImport + parentRoute: typeof rootRoute + } '/calendar/': { id: '/calendar/' path: '/calendar' @@ -159,6 +172,7 @@ export interface FileRoutesByFullPath { '/events/$eventId': typeof EventsEventIdRoute '/events/create': typeof EventsCreateRoute '/home/infoCard': typeof HomeInfoCardRoute + '/sales/add_sell': typeof SalesAddsellRoute '/calendar': typeof CalendarIndexRoute '/dinner': typeof DinnerIndexRoute '/events': typeof EventsIndexRoute @@ -172,6 +186,7 @@ export interface FileRoutesByTo { '/events/$eventId': typeof EventsEventIdRoute '/events/create': typeof EventsCreateRoute '/home/infoCard': typeof HomeInfoCardRoute + '/sales/add_sell': typeof SalesAddsellRoute '/calendar': typeof CalendarIndexRoute '/dinner': typeof DinnerIndexRoute '/events': typeof EventsIndexRoute @@ -186,6 +201,7 @@ export interface FileRoutesById { '/events/$eventId': typeof EventsEventIdRoute '/events/create': typeof EventsCreateRoute '/home/infoCard': typeof HomeInfoCardRoute + '/sales/add_sell': typeof SalesAddsellRoute '/calendar/': typeof CalendarIndexRoute '/dinner/': typeof DinnerIndexRoute '/events/': typeof EventsIndexRoute @@ -201,6 +217,7 @@ export interface FileRouteTypes { | '/events/$eventId' | '/events/create' | '/home/infoCard' + | '/sales/add_sell' | '/calendar' | '/dinner' | '/events' @@ -213,6 +230,7 @@ export interface FileRouteTypes { | '/events/$eventId' | '/events/create' | '/home/infoCard' + | '/sales/add_sell' | '/calendar' | '/dinner' | '/events' @@ -225,6 +243,7 @@ export interface FileRouteTypes { | '/events/$eventId' | '/events/create' | '/home/infoCard' + | '/sales/add_sell' | '/calendar/' | '/dinner/' | '/events/' @@ -239,6 +258,7 @@ export interface RootRouteChildren { EventsEventIdRoute: typeof EventsEventIdRoute EventsCreateRoute: typeof EventsCreateRoute HomeInfoCardRoute: typeof HomeInfoCardRoute + SalesAddsellRoute: typeof SalesAddsellRoute CalendarIndexRoute: typeof CalendarIndexRoute DinnerIndexRoute: typeof DinnerIndexRoute EventsIndexRoute: typeof EventsIndexRoute @@ -252,6 +272,7 @@ const rootRouteChildren: RootRouteChildren = { EventsEventIdRoute: EventsEventIdRoute, EventsCreateRoute: EventsCreateRoute, HomeInfoCardRoute: HomeInfoCardRoute, + SalesAddsellRoute: SalesAddsellRoute, CalendarIndexRoute: CalendarIndexRoute, DinnerIndexRoute: DinnerIndexRoute, EventsIndexRoute: EventsIndexRoute, @@ -276,6 +297,7 @@ export const routeTree = rootRoute "/events/$eventId", "/events/create", "/home/infoCard", + "/sales/add_sell", "/calendar/", "/dinner/", "/events/", @@ -298,6 +320,9 @@ export const routeTree = rootRoute "/home/infoCard": { "filePath": "home/infoCard.tsx" }, + "/sales/add_sell": { + "filePath": "sales/add_sell.tsx" + }, "/calendar/": { "filePath": "calendar/index.tsx" }, diff --git a/src/routes/sales/add_sell.tsx b/src/routes/sales/add_sell.tsx new file mode 100644 index 0000000..26cf916 --- /dev/null +++ b/src/routes/sales/add_sell.tsx @@ -0,0 +1,132 @@ +import { createFileRoute } from '@tanstack/react-router'; +import { Header } from '../../components'; +import { BasicIcon } from '../../components/icons/BasicIcon'; +import { AuthGuard } from '../../utils/auth'; +import { supabase } from '../../utils/supabase'; + +const styles = { + container: { + flex: 1, + backgroundColor: '#333', + }, + searchSection: { + display: 'flex', + alignItems: 'center', + padding: 4, + backgroundColor: '#333', + }, + searchInput: { + flex: 1, + marginLeft: 8, + marginRight: 8, + backgroundColor: '#f0f0f0', + borderRadius: 5, + padding: 4, + }, + categories: { + display: 'inline', + padding: 5, + }, + categoryButton: { + paddingLeft: 8, + paddingRight: 8, + margin: 2, + backgroundColor: '#888', + borderRadius: 12, + color: 'black', + }, + grid: { + padding: 10, + display: 'flex', + justifyContent: 'space-between', + gap: 10, + }, + card: { + width: '50%', + marginBottom: 10, + padding: 10, + backgroundColor: '#555', + borderRadius: 10, + color: 'white', + }, + productName: { + fontSize: 16, + color: 'white', + }, + productInfo: { + fontSize: 14, + color: 'gray', + }, + icon: { + alignSelf: 'flex-end', + }, + fab: { + position: 'absolute', + bottom: 20, + right: 20, + backgroundColor: '#6200ee', + width: 60, + height: 60, + borderRadius: 30, + justifyContent: 'center', + alignItems: 'center', + }, +}; + +export const Route = createFileRoute('/sales/add_sell')({ + beforeLoad: AuthGuard, + loader: async () => { + const { data, error } = await supabase + .from('sales') + .select('*') + if (error !== null) { + throw error + } + + return { sales: data } + }, + component: EventSale +}) +function EventSale() { + const { sales } = Route.useLoaderData() + return ( + <> +
+
+
+ + + + + + + +
+
+ + + + +
+
+ { + sales.map((p) => ( +
+

{p.product}

+

價格: {p.price} 元

+
+ )) + }{ + sales.map((p) => ( +
+

{p.product}

+

價格: {p.price} 元

+
+ )) + } +
+
+ + ) + } + \ No newline at end of file From 42233472f2640476270c6ed0bcc2d9d80d6979f4 Mon Sep 17 00:00:00 2001 From: Angle Date: Sun, 24 Nov 2024 00:48:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=9F=BA=E7=A4=8Esell=E4=BB=8B=E9=9D=A2v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 8 ++++---- package.json | 2 +- src/routes/sales/add_sell.tsx | 22 +++++++++------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 70e1702..788a138 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.6", "postcss": "^8.4.45", - "tailwindcss": "^3.4.10", + "tailwindcss": "^3.4.14", "typescript": "^5.2.2", "vite": "^5.2.10", "vite-plugin-pwa": "^0.20.0", @@ -8169,9 +8169,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.4.10", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.10.tgz", - "integrity": "sha512-KWZkVPm7yJRhdu4SRSl9d4AK2wM3a50UsvgHZO7xY77NQr2V+fIrEuoDGQcbvswWvFGbS2f6e+jC/6WJm1Dl0w==", + "version": "3.4.14", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.14.tgz", + "integrity": "sha512-IcSvOcTRcUtQQ7ILQL5quRDg7Xs93PdJEk1ZLbhhvJc7uj/OAhYOnruEiwnGgBvUtaUAJ8/mhSw1o8L2jCiENA==", "dev": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", diff --git a/package.json b/package.json index 1afabaf..9750033 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.6", "postcss": "^8.4.45", - "tailwindcss": "^3.4.10", + "tailwindcss": "^3.4.14", "typescript": "^5.2.2", "vite": "^5.2.10", "vite-plugin-pwa": "^0.20.0", diff --git a/src/routes/sales/add_sell.tsx b/src/routes/sales/add_sell.tsx index 26cf916..f2e9b72 100644 --- a/src/routes/sales/add_sell.tsx +++ b/src/routes/sales/add_sell.tsx @@ -36,18 +36,21 @@ const styles = { color: 'black', }, grid: { - padding: 10, + padding: '10px', display: 'flex', + flexWrap: 'wrap', + gap: '10px', justifyContent: 'space-between', - gap: 10, }, card: { - width: '50%', - marginBottom: 10, - padding: 10, + flex: '1 1 calc(25% - 10px)', + maxWidth: 'calc(25% - 10px)', + marginBottom: '10px', + padding: '10px', backgroundColor: '#555', - borderRadius: 10, + borderRadius: '10px', color: 'white', + boxSizing: 'border-box', }, productName: { fontSize: 16, @@ -116,13 +119,6 @@ function EventSale() {

價格: {p.price} 元

)) - }{ - sales.map((p) => ( -
-

{p.product}

-

價格: {p.price} 元

-
- )) } From 1c55448729c9b3d1dcd67df7aea1ccb1a0723417 Mon Sep 17 00:00:00 2001 From: Susan Chen <92381825+1989ONCE@users.noreply.github.com> Date: Tue, 3 Dec 2024 19:03:40 +0800 Subject: [PATCH 3/3] remove unwanted file --- .env | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index b4769f9..0000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -VITE_SUPABASE_URL=http://127.0.0.1:54321 -VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0