diff --git a/client/src/components/Capture.jsx b/client/src/components/Capture.jsx index beae592..17b9c31 100644 --- a/client/src/components/Capture.jsx +++ b/client/src/components/Capture.jsx @@ -4,27 +4,49 @@ import { useAuth0 } from '@auth0/auth0-react' export default function Capture() { const { user } = useAuth0() const [metadata, setMetadata] = useState({ customerId: '' }) - const [userId, setUserId] = useState('userId') + const [userInfo, setUserInfo] = useState('userId') const [productId, setProductId] = useState(import.meta.env.VITE_STRIPE_PRODUCT_ID) + const quarterlyId = import.meta.env.VITE_STRIPE_QUARTERLY_PRODUCT_ID + const yearlyId = import.meta.env.VITE_STRIPE_YEARLY_PRODUCT_ID useEffect(() => { if (user) { setMetadata(user[`${import.meta.env.VITE_AUTH0_NAMESPACE}/app_metadata`]) - setUserId(user.sub) + setUserInfo({userId: user.sub, email: user.email}) } }, [user]) return ( <> +

You need to subscribe to access the app.

+
Select an option below
-

You need to subscribe

-
Price is $35 / month
+
Monthly Subscription - $35 / month
- + +
+
+
Quarterly Subscription - $100 / 3 months (save $5)
+
+ + + + +
+
+
+
Yearly Subscription - $350 / year (save $70)
+
+ + + + +
+
) } diff --git a/client/src/components/Sidebar.jsx b/client/src/components/Sidebar.jsx index 10fd4a7..ff47c91 100644 --- a/client/src/components/Sidebar.jsx +++ b/client/src/components/Sidebar.jsx @@ -16,7 +16,9 @@ import { Link } from 'react-router-dom'; const Sidebar = () => { // Retrieve the isAdmin context from the Outlet context - const { isAdmin } = useOutletContext(); + // const { isAdmin } = useOutletContext(); + // temporary sidebar adjustment (how do we get isAdmin) + const isAdmin = false const { logout } = useAuth0(); const handleLogout = () => { diff --git a/client/src/routes/AdminDashboard.jsx b/client/src/routes/AdminDashboard.jsx index d4ef479..c070211 100644 --- a/client/src/routes/AdminDashboard.jsx +++ b/client/src/routes/AdminDashboard.jsx @@ -48,7 +48,7 @@ export const AdminDashboard = ({admin}) => { const { logout, user } = useAuth0(); const { getAllFileMetadata } = useFileMetadataContext(); const navigate = useNavigate() - const metadata = user[`${import.meta.env.VITE_AUTH0_NAMESPACE}/user_metadata`] + const metadata = user[`${import.meta.env.VITE_AUTH0_NAMESPACE}/app_metadata`] useEffect(() => { getAllFileMetadata() diff --git a/routes/stripeRouter.js b/routes/stripeRouter.js index 13403eb..2b1eb51 100644 --- a/routes/stripeRouter.js +++ b/routes/stripeRouter.js @@ -43,6 +43,11 @@ stripeRouter.get('/confirm', async (req, res, next) => { stripeRouter.post('/create-checkout-session', async (req, res, next) => { const userId = req.body.customer + const userEmail = req.body.email + // error handling for userId + if (!userId || !userEmail) { + res.status(400).send('User ID & Email is required'); + } // price comes from the frontend form, which stores productIds inside of env variables instead of loooking them up via stripe api const subscriptionPriceLookupKey = req.body.productId @@ -58,6 +63,7 @@ stripeRouter.post('/create-checkout-session', async (req, res, next) => { // sucess_url provides auth0 userId & stripe session.id success_url: `${process.env.STRIPE_SUCCESS_URI}&userId=${userId}&session_id={CHECKOUT_SESSION_ID}`, cancel_url: `${process.env.STRIPE_FAILURE_URI}&userId=${userId}`, + customer_email: userEmail }) res.redirect(303, session.url)