-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: surajr10 <[email protected]>
- Loading branch information
Showing
5 changed files
with
57 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
module.exports = { | ||
extends: ["@calblueprint/eslint-config-react"], | ||
extends: ["@calblueprint/eslint-config-react"], | ||
rules: { | ||
// Add any custom rules here | ||
// Disable the rule that requires React to be in scope -- we don't need this with React 18 | ||
'react/react-in-jsx-scope': 'off', | ||
'react/jsx-uses-react': 'off', | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
typescript: {} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,45 @@ | ||
'use client'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
import { useEffect, useState } from 'react'; | ||
import supabase from '@/api/supabase/createClient'; | ||
import { fetchUserByUUID } from '@/api/supabase/queries/user_queries'; | ||
import { Button } from '../login/styles'; | ||
|
||
import NavBar from '../../components/NavBar'; | ||
|
||
export default function Checkout() { | ||
const [deliveryEnabled, setDeliveryEnabled] = useState<boolean>(false); | ||
useEffect(() => { | ||
(async () => { | ||
const { data: sessionData, error } = await supabase.auth.getSession(); | ||
|
||
if (error) throw error; | ||
if ( | ||
!sessionData || | ||
!sessionData.session || | ||
!sessionData.session.user || | ||
!sessionData.session.user.id | ||
) | ||
return; | ||
|
||
const data = await fetchUserByUUID(sessionData.session.user.id as string); | ||
setDeliveryEnabled(data.delivery_allowed); | ||
})(); | ||
}, []); | ||
|
||
const router = useRouter(); | ||
const checkDelivery = () => { | ||
if (deliveryEnabled) { | ||
router.push('/delivery'); | ||
} else { | ||
router.push('/pickup'); | ||
} | ||
}; | ||
return ( | ||
<main> | ||
<NavBar /> | ||
<div>Checkout</div> | ||
<Button onClick={checkDelivery}>Checkout</Button> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters