From 0f6a2341af9d4e4ad695e283d8f2593e6604a426 Mon Sep 17 00:00:00 2001 From: Buyankhuu Tsolmonkhuu Date: Fri, 5 Apr 2024 19:24:37 -0700 Subject: [PATCH] switchBranch --- src/api/supabase/queries/order_queries.ts | 3 ++- src/app/orderConfirmationDelivery/page.tsx | 3 ++- src/app/orderConfirmationPickUp/page.tsx | 4 ++-- src/app/profileScreen/page.tsx | 4 ++-- src/app/storefront/StoreFrontNavBar.tsx | 1 - 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/api/supabase/queries/order_queries.ts b/src/api/supabase/queries/order_queries.ts index 4246a8a6..ed459478 100644 --- a/src/api/supabase/queries/order_queries.ts +++ b/src/api/supabase/queries/order_queries.ts @@ -5,6 +5,7 @@ import { Order, OrderProduct, Product } from '../../../schema/schema'; import { fetchUser } from './user_queries'; import { fetchProductByID } from './product_queries'; import supabase from '../createClient'; +import { randomUUID } from 'crypto'; /** * Fetches all orders from the database. @@ -40,7 +41,7 @@ export async function createOrder() { await supabase .from('users') - .update({ cart_id: order.id }) + .update({ cart_id: order.ID }) .match({ id: user.id }); } diff --git a/src/app/orderConfirmationDelivery/page.tsx b/src/app/orderConfirmationDelivery/page.tsx index af027295..0cb82141 100644 --- a/src/app/orderConfirmationDelivery/page.tsx +++ b/src/app/orderConfirmationDelivery/page.tsx @@ -5,7 +5,7 @@ import { fetchUser, fetchUserAddress, } from '@/api/supabase/queries/user_queries'; - +import { createOrder } from '@/api/supabase/queries/order_queries'; import { Body2, Heading3Bold } from '@/styles/fonts'; import BackButton from '../../components/BackButton/BackButton'; @@ -31,6 +31,7 @@ export default function OrderConfirmationDelivery() { const [Cart, setCart] = useState([]); const [user, setUser] = useState(); const [userAddress, setUserAddress] = useState
(); + createOrder(); useEffect(() => { async function fetchProducts() { diff --git a/src/app/orderConfirmationPickUp/page.tsx b/src/app/orderConfirmationPickUp/page.tsx index 65b42154..bddefe17 100644 --- a/src/app/orderConfirmationPickUp/page.tsx +++ b/src/app/orderConfirmationPickUp/page.tsx @@ -4,7 +4,7 @@ import { useState, useEffect } from 'react'; import { fetchUser } from '@/api/supabase/queries/user_queries'; import { fetchPickupTimesByID } from '@/api/supabase/queries/pickup_queries'; -import { fetchCurrentOrdersByUser } from '@/api/supabase/queries/order_queries'; +import { fetchCurrentOrdersByUser, createOrder} from '@/api/supabase/queries/order_queries'; import { Body2Bold, Body2, Heading3Bold } from '@/styles/fonts'; import { fetchCartItemsWithQuantity } from '../../api/supabase/queries/cart_queries'; @@ -45,7 +45,7 @@ export default function OrderConfirmationPickUp() { const pickup = await fetchPickupTimesByID(currOrder[0].pickup_time_id); setPickupTime(pickup); } - + createOrder(); fetchProducts(); setUserDetails(); }, []); diff --git a/src/app/profileScreen/page.tsx b/src/app/profileScreen/page.tsx index 7ac86512..4fef4f31 100644 --- a/src/app/profileScreen/page.tsx +++ b/src/app/profileScreen/page.tsx @@ -131,9 +131,9 @@ function AccountDetailSectionDelivery(props: { user: User }) { Name - + {user?.first_name} {user?.last_name} - + Address diff --git a/src/app/storefront/StoreFrontNavBar.tsx b/src/app/storefront/StoreFrontNavBar.tsx index 2642b4a9..5820cef5 100644 --- a/src/app/storefront/StoreFrontNavBar.tsx +++ b/src/app/storefront/StoreFrontNavBar.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/button-has-type */ import Image from 'next/image'; import Link from 'next/link'; import React, { useEffect, useState } from 'react';