Skip to content

Commit

Permalink
feat/eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Cai committed Oct 8, 2023
1 parent d8aca4e commit eca47ea
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 133 deletions.
140 changes: 54 additions & 86 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,4 +35,4 @@ export type Product = {
description: string; // text null;
category: number; // numeric not null;
quantity: number; // numeric not null;
}
};
37 changes: 27 additions & 10 deletions src/supabase/order_queries.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -8,9 +16,9 @@ const supabaseApiKey = 'YOUR_SUPABASE_API_KEY';
// Initialize the Supabase client
const supabase = createClient(supabaseUrl, supabaseApiKey);



async function fetchOrders(): Promise<PostgrestSingleResponse<Order[]> | { data: never[]; error: PostgrestError }>{
async function fetchOrders(): Promise<
PostgrestSingleResponse<Order[]> | { data: never[]; error: PostgrestError }
> {
try {
const { data: orders, error } = await supabase
.from('Order') // Update to the "Order" table
Expand All @@ -29,7 +37,9 @@ async function fetchOrders(): Promise<PostgrestSingleResponse<Order[]> | { data:
}
}

async function fetchOrderByUUID(uuid: string): Promise<PostgrestSingleResponse<Order>> {
async function fetchOrderByUUID(
uuid: string,
): Promise<PostgrestSingleResponse<Order>> {
try {
const { data: order, error } = await supabase
.from('Order') // Update to the "Order" table
Expand All @@ -48,7 +58,11 @@ async function fetchOrderByUUID(uuid: string): Promise<PostgrestSingleResponse<O
}
}

async function getOrdersByUserId(userId: string): Promise<PostgrestSingleResponse<Order[]> | { data: never[]; error: PostgrestError }> {
async function getOrdersByUserId(
userId: string,
): Promise<
PostgrestSingleResponse<Order[]> | { data: never[]; error: PostgrestError }
> {
try {
const { data: orders, error } = await supabase
.from('Order')
Expand All @@ -69,7 +83,9 @@ async function getOrdersByUserId(userId: string): Promise<PostgrestSingleRespons
}

// Function to get an order by its ID
async function getOrderById(orderId: string): Promise<PostgrestSingleResponse<Order>> {
async function getOrderById(
orderId: string,
): Promise<PostgrestSingleResponse<Order>> {
try {
const { data: order, error } = await supabase
.from('Order')
Expand All @@ -88,7 +104,9 @@ async function getOrderById(orderId: string): Promise<PostgrestSingleResponse<Or
}
}

async function toggleOrderProgress(orderId: string): Promise<PostgrestSingleResponse<Order>> {
async function toggleOrderProgress(
orderId: string,
): Promise<PostgrestSingleResponse<Order>> {
try {
// Fetch the order by ID to get its current "approved" value
const { data: currentOrder, error: fetchError } = await supabase
Expand Down Expand Up @@ -142,4 +160,3 @@ async function updateAllOrdersProgressToTrue(): Promise<boolean | string> {
return 'Update failed'; // Return an error message if an exception occurs
}
}

Loading

0 comments on commit eca47ea

Please sign in to comment.