From eca47ea524b9a2596595f8e93ede1c499085d46a Mon Sep 17 00:00:00 2001 From: Kevin Cai Date: Sun, 8 Oct 2023 15:23:05 -0700 Subject: [PATCH] feat/eslint --- package-lock.json | 140 ++++++++++++------------------ package.json | 2 +- src/schema/schema.ts | 3 +- src/supabase/order_queries.ts | 37 +++++--- src/supabase/pickup_queries.ts | 24 +++-- src/supabase/product_queries.ts | 24 +++-- src/supabase/queries.ts | 2 - src/supabase/user_queries copy.ts | 39 +++++---- 8 files changed, 138 insertions(+), 133 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80b6bf43..96ef1f18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@types/react-dom": "18.2.7", "dotenv": "^16.3.1", "eslint-config-next": "13.5.2", - "next": "13.5.2", + "next": "^13.5.4", "react": "18.2.0", "react-dom": "18.2.0", "styled-components": "^6.0.8" @@ -2226,9 +2226,9 @@ } }, "node_modules/@next/env": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.2.tgz", - "integrity": "sha512-dUseBIQVax+XtdJPzhwww4GetTjlkRSsXeQnisIJWBaHsnxYcN2RGzsPHi58D6qnkATjnhuAtQTJmR1hKYQQPg==" + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.4.tgz", + "integrity": "sha512-LGegJkMvRNw90WWphGJ3RMHMVplYcOfRWf2Be3td3sUa+1AaxmsYyANsA+znrGCBjXJNi4XAQlSoEfUxs/4kIQ==" }, "node_modules/@next/eslint-plugin-next": { "version": "13.5.2", @@ -2239,9 +2239,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.2.tgz", - "integrity": "sha512-7eAyunAWq6yFwdSQliWMmGhObPpHTesiKxMw4DWVxhm5yLotBj8FCR4PXGkpRP2tf8QhaWuVba+/fyAYggqfQg==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.4.tgz", + "integrity": "sha512-Df8SHuXgF1p+aonBMcDPEsaahNo2TCwuie7VXED4FVyECvdXfRT9unapm54NssV9tF3OQFKBFOdlje4T43VO0w==", "cpu": [ "arm64" ], @@ -2254,9 +2254,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.2.tgz", - "integrity": "sha512-WxXYWE7zF1ch8rrNh5xbIWzhMVas6Vbw+9BCSyZvu7gZC5EEiyZNJsafsC89qlaSA7BnmsDXVWQmc+s1feSYbQ==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.4.tgz", + "integrity": "sha512-siPuUwO45PnNRMeZnSa8n/Lye5ZX93IJom9wQRB5DEOdFrw0JjOMu1GINB8jAEdwa7Vdyn1oJ2xGNaQpdQQ9Pw==", "cpu": [ "x64" ], @@ -2269,9 +2269,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.2.tgz", - "integrity": "sha512-URSwhRYrbj/4MSBjLlefPTK3/tvg95TTm6mRaiZWBB6Za3hpHKi8vSdnCMw5D2aP6k0sQQIEG6Pzcfwm+C5vrg==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.4.tgz", + "integrity": "sha512-l/k/fvRP/zmB2jkFMfefmFkyZbDkYW0mRM/LB+tH5u9pB98WsHXC0WvDHlGCYp3CH/jlkJPL7gN8nkTQVrQ/2w==", "cpu": [ "arm64" ], @@ -2284,9 +2284,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.2.tgz", - "integrity": "sha512-HefiwAdIygFyNmyVsQeiJp+j8vPKpIRYDlmTlF9/tLdcd3qEL/UEBswa1M7cvO8nHcr27ZTKXz5m7dkd56/Esg==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.4.tgz", + "integrity": "sha512-YYGb7SlLkI+XqfQa8VPErljb7k9nUnhhRrVaOdfJNCaQnHBcvbT7cx/UjDQLdleJcfyg1Hkn5YSSIeVfjgmkTg==", "cpu": [ "arm64" ], @@ -2299,9 +2299,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.2.tgz", - "integrity": "sha512-htGVVroW0tdHgMYwKWkxWvVoG2RlAdDXRO1RQxYDvOBQsaV0nZsgKkw0EJJJ3urTYnwKskn/MXm305cOgRxD2w==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.4.tgz", + "integrity": "sha512-uE61vyUSClnCH18YHjA8tE1prr/PBFlBFhxBZis4XBRJoR+txAky5d7gGNUIbQ8sZZ7LVkSVgm/5Fc7mwXmRAg==", "cpu": [ "x64" ], @@ -2314,9 +2314,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.2.tgz", - "integrity": "sha512-UBD333GxbHVGi7VDJPPDD1bKnx30gn2clifNJbla7vo5nmBV+x5adyARg05RiT9amIpda6yzAEEUu+s774ldkw==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.4.tgz", + "integrity": "sha512-qVEKFYML/GvJSy9CfYqAdUexA6M5AklYcQCW+8JECmkQHGoPxCf04iMh7CPR7wkHyWWK+XLt4Ja7hhsPJtSnhg==", "cpu": [ "x64" ], @@ -2329,9 +2329,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.2.tgz", - "integrity": "sha512-Em9ApaSFIQnWXRT3K6iFnr9uBXymixLc65Xw4eNt7glgH0eiXpg+QhjmgI2BFyc7k4ZIjglfukt9saNpEyolWA==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.4.tgz", + "integrity": "sha512-mDSQfqxAlfpeZOLPxLymZkX0hYF3juN57W6vFHTvwKlnHfmh12Pt7hPIRLYIShk8uYRsKPtMTth/EzpwRI+u8w==", "cpu": [ "arm64" ], @@ -2344,9 +2344,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.2.tgz", - "integrity": "sha512-TBACBvvNYU+87X0yklSuAseqdpua8m/P79P0SG1fWUvWDDA14jASIg7kr86AuY5qix47nZLEJ5WWS0L20jAUNw==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.4.tgz", + "integrity": "sha512-aoqAT2XIekIWoriwzOmGFAvTtVY5O7JjV21giozBTP5c6uZhpvTWRbmHXbmsjZqY4HnEZQRXWkSAppsIBweKqw==", "cpu": [ "ia32" ], @@ -2359,9 +2359,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.2.tgz", - "integrity": "sha512-LfTHt+hTL8w7F9hnB3H4nRasCzLD/fP+h4/GUVBTxrkMJOnh/7OZ0XbYDKO/uuWwryJS9kZjhxcruBiYwc5UDw==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.4.tgz", + "integrity": "sha512-cyRvlAxwlddlqeB9xtPSfNSCRy8BOa4wtMo0IuI9P7Y0XT2qpDrpFKRyZ7kUngZis59mPVla5k8X1oOJ8RxDYg==", "cpu": [ "x64" ], @@ -5511,18 +5511,17 @@ "peer": true }, "node_modules/next": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/next/-/next-13.5.2.tgz", - "integrity": "sha512-vog4UhUaMYAzeqfiAAmgB/QWLW7p01/sg+2vn6bqc/CxHFYizMzLv6gjxKzl31EVFkfl/F+GbxlKizlkTE9RdA==", + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/next/-/next-13.5.4.tgz", + "integrity": "sha512-+93un5S779gho8y9ASQhb/bTkQF17FNQOtXLKAj3lsNgltEcF0C5PMLLncDmH+8X1EnJH1kbqAERa29nRXqhjA==", "dependencies": { - "@next/env": "13.5.2", + "@next/env": "13.5.4", "@swc/helpers": "0.5.2", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", - "postcss": "8.4.14", + "postcss": "8.4.31", "styled-jsx": "5.1.1", - "watchpack": "2.4.0", - "zod": "3.21.4" + "watchpack": "2.4.0" }, "bin": { "next": "dist/bin/next" @@ -5531,15 +5530,15 @@ "node": ">=16.14.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.5.2", - "@next/swc-darwin-x64": "13.5.2", - "@next/swc-linux-arm64-gnu": "13.5.2", - "@next/swc-linux-arm64-musl": "13.5.2", - "@next/swc-linux-x64-gnu": "13.5.2", - "@next/swc-linux-x64-musl": "13.5.2", - "@next/swc-win32-arm64-msvc": "13.5.2", - "@next/swc-win32-ia32-msvc": "13.5.2", - "@next/swc-win32-x64-msvc": "13.5.2" + "@next/swc-darwin-arm64": "13.5.4", + "@next/swc-darwin-x64": "13.5.4", + "@next/swc-linux-arm64-gnu": "13.5.4", + "@next/swc-linux-arm64-musl": "13.5.4", + "@next/swc-linux-x64-gnu": "13.5.4", + "@next/swc-linux-x64-musl": "13.5.4", + "@next/swc-win32-arm64-msvc": "13.5.4", + "@next/swc-win32-ia32-msvc": "13.5.4", + "@next/swc-win32-x64-msvc": "13.5.4" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -5819,9 +5818,9 @@ } }, "node_modules/postcss": { - "version": "8.4.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", - "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "funding": [ { "type": "opencollective", @@ -5830,10 +5829,14 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { - "nanoid": "^3.3.4", + "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, @@ -6462,33 +6465,6 @@ } } }, - "node_modules/styled-components/node_modules/postcss": { - "version": "8.4.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", - "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "nanoid": "^3.3.6", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, "node_modules/styled-jsx": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz", @@ -7105,14 +7081,6 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/zod": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } } } } diff --git a/package.json b/package.json index 8116a82f..be101eab 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@types/react-dom": "18.2.7", "dotenv": "^16.3.1", "eslint-config-next": "13.5.2", - "next": "13.5.2", + "next": "^13.5.4", "react": "18.2.0", "react-dom": "18.2.0", "styled-components": "^6.0.8" diff --git a/src/schema/schema.ts b/src/schema/schema.ts index 21d9f383..d09310be 100644 --- a/src/schema/schema.ts +++ b/src/schema/schema.ts @@ -12,7 +12,6 @@ export type User = { zipcode: string[]; }; - export type Order = { id: number; // bigint generated by default as identity user_id: string; // UUID not null @@ -36,4 +35,4 @@ export type Product = { description: string; // text null; category: number; // numeric not null; quantity: number; // numeric not null; -} +}; diff --git a/src/supabase/order_queries.ts b/src/supabase/order_queries.ts index dade93d8..4d5a7d4a 100644 --- a/src/supabase/order_queries.ts +++ b/src/supabase/order_queries.ts @@ -1,5 +1,13 @@ -import { PostgrestSingleResponse, PostgrestError, createClient } from '@supabase/supabase-js'; -import { Order } from '../../types/schema'; +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable no-console */ +// + +import { + PostgrestSingleResponse, + PostgrestError, + createClient, +} from '@supabase/supabase-js'; +import { Order } from '../schema/schema'; // Replace these with your Supabase project URL and API key const supabaseUrl = 'YOUR_SUPABASE_URL'; @@ -8,9 +16,9 @@ const supabaseApiKey = 'YOUR_SUPABASE_API_KEY'; // Initialize the Supabase client const supabase = createClient(supabaseUrl, supabaseApiKey); - - -async function fetchOrders(): Promise | { data: never[]; error: PostgrestError }>{ +async function fetchOrders(): Promise< + PostgrestSingleResponse | { data: never[]; error: PostgrestError } +> { try { const { data: orders, error } = await supabase .from('Order') // Update to the "Order" table @@ -29,7 +37,9 @@ async function fetchOrders(): Promise | { data: } } -async function fetchOrderByUUID(uuid: string): Promise> { +async function fetchOrderByUUID( + uuid: string, +): Promise> { try { const { data: order, error } = await supabase .from('Order') // Update to the "Order" table @@ -48,7 +58,11 @@ async function fetchOrderByUUID(uuid: string): Promise | { data: never[]; error: PostgrestError }> { +async function getOrdersByUserId( + userId: string, +): Promise< + PostgrestSingleResponse | { data: never[]; error: PostgrestError } +> { try { const { data: orders, error } = await supabase .from('Order') @@ -69,7 +83,9 @@ async function getOrdersByUserId(userId: string): Promise> { +async function getOrderById( + orderId: string, +): Promise> { try { const { data: order, error } = await supabase .from('Order') @@ -88,7 +104,9 @@ async function getOrderById(orderId: string): Promise> { +async function toggleOrderProgress( + orderId: string, +): Promise> { try { // Fetch the order by ID to get its current "approved" value const { data: currentOrder, error: fetchError } = await supabase @@ -142,4 +160,3 @@ async function updateAllOrdersProgressToTrue(): Promise { return 'Update failed'; // Return an error message if an exception occurs } } - diff --git a/src/supabase/pickup_queries.ts b/src/supabase/pickup_queries.ts index d067e522..d78b2560 100644 --- a/src/supabase/pickup_queries.ts +++ b/src/supabase/pickup_queries.ts @@ -1,5 +1,13 @@ -import { PostgrestSingleResponse, PostgrestError, createClient } from '@supabase/supabase-js'; -import { Schedule } from '../../types/schema'; +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable no-console */ +// + +import { + PostgrestSingleResponse, + PostgrestError, + createClient, +} from '@supabase/supabase-js'; +import { Schedule } from '../schema/schema'; // Replace these with your Supabase project URL and API key const supabaseUrl = 'YOUR_SUPABASE_URL'; @@ -8,9 +16,9 @@ const supabaseApiKey = 'YOUR_SUPABASE_API_KEY'; // Initialize the Supabase client const supabase = createClient(supabaseUrl, supabaseApiKey); - - -async function fetchData(): Promise | { data: never[]; error: PostgrestError }> { +async function fetchData(): Promise< + PostgrestSingleResponse | { data: never[]; error: PostgrestError } +> { try { const { data: pickupTimes, error } = await supabase .from('Pickup_Times') @@ -29,7 +37,9 @@ async function fetchData(): Promise | { data } } -async function fetchPickupTimesByUUID(uuid: string): Promise> { +async function fetchPickupTimesByUUID( + uuid: string, +): Promise> { try { const { data: pickupTimes, error } = await supabase .from('Pickup_Times') @@ -47,5 +57,3 @@ async function fetchPickupTimesByUUID(uuid: string): Promise | { data: never[]; error: PostgrestError }> { +async function fetchProducts(): Promise< + PostgrestSingleResponse | { data: never[]; error: PostgrestError } +> { try { const { data: products, error } = await supabase .from('Product') @@ -29,8 +36,9 @@ async function fetchProducts(): Promise | { d } } - -async function fetchProductByName(productName: string): Promise> { +async function fetchProductByName( + productName: string, +): Promise> { try { const { data: product, error } = await supabase .from('Product') @@ -48,5 +56,3 @@ async function fetchProductByName(productName: string): Promise | { data: never[]; error: PostgrestError }> -{ +async function fetchData(): Promise< + PostgrestSingleResponse | { data: never[]; error: PostgrestError } +> { try { const { data: users, error } = await supabase .from('Users') @@ -26,11 +33,12 @@ async function fetchData(): Promise | { data: ne } catch (error) { console.error('Error:', error); throw error; - } } -async function fetchUserByUUID(uuid: string): Promise> { +async function fetchUserByUUID( + uuid: string, +): Promise> { try { const { data: user, error } = await supabase .from('Users') @@ -49,15 +57,12 @@ async function fetchUserByUUID(uuid: string): Promise> { + newZipcode: string, +): Promise> { try { const { data: existingUser, error: selectError } = await supabase .from('Users') @@ -77,7 +82,11 @@ async function addUserAddress( const { data, error } = await supabase .from('Users') - .update({ street: updatedStreet, city: updatedCity, zipcode: updatedZipcode }) + .update({ + street: updatedStreet, + city: updatedCity, + zipcode: updatedZipcode, + }) .eq('user_id', uuid) .single(); @@ -91,4 +100,4 @@ async function addUserAddress( console.error('Error:', error); throw error; } -} \ No newline at end of file +}