This file contains hidden or 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
| import Header from "/components/Header"; | |
| import {useRouter} from "next/router"; | |
| function ThankYou() { | |
| const router = useRouter(); | |
| return ( | |
| <div> | |
| <Header /> | |
| <div className="container mx-auto"> |
This file contains hidden or 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
| import { Provider } from 'react-redux' | |
| import { store } from '../redux/store' | |
| import '../styles/globals.css' | |
| import Head from 'next/head'; | |
| import { PayPalScriptProvider } from "@paypal/react-paypal-js"; | |
| const MyApp = ({ Component, pageProps }) => { | |
| return ( | |
| <PayPalScriptProvider options= {{"client-id": process.env.paypal_client_id }}> | |
| <Provider store={store}> |
This file contains hidden or 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
| import { PayPalButtons } from "@paypal/react-paypal-js"; | |
| import PaymentProduct from "/components/PaymentProduct" | |
| import { useState } from "react"; | |
| import {useRouter} from "next/router"; | |
| import { useSelector } from "react-redux"; | |
| import { selectItems, selectTotal } from "/redux/basketSlice" | |
| function PaypalCheckout() { | |
| const [succeeded, setSucceeded] = useState(false); |
This file contains hidden or 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
| import Image from "next/image"; | |
| function PaymentProduct({id, title, price, description, image}) { | |
| return ( | |
| <div className='grid grid-cols-3'> | |
| {/* Left */} | |
| <Image src={image} height={200} width={200} objectFit="contain" /> | |
| {/* Middle */} | |
| <div className="col-span-3 mx-5"> |
This file contains hidden or 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
| import Header from "components/Header"; | |
| import { useSelector } from "react-redux"; | |
| import { selectItems, selectTotal } from "redux/basketSlice" | |
| import CheckoutProduct from "components/CheckoutProduct" | |
| import {useRouter} from "next/router"; | |
| import { userService } from 'pages/services/user.service'; | |
| function Checkout() { | |
| const items = useSelector(selectItems); | |
| const total = useSelector(selectTotal); |
This file contains hidden or 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
| import Image from "next/image"; | |
| import { StarIcon } from "@heroicons/react/solid"; | |
| import { useDispatch } from "react-redux" | |
| import {addToBasket, removeFromBasket} from "redux/basketSlice"; | |
| function CheckoutProduct({id, title, price, rating, description, category, image}) { | |
| const dispatch = useDispatch(); | |
| const addItemToBasket = () => { | |
| const product = { |
This file contains hidden or 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
| function Header(){ | |
| return ( | |
| <div> | |
| {/*Account & basket*/} | |
| <div className="text-white flex item-center text-xs space-x-6 mx-6 whitespace-nowrap"> | |
| <div onClick={userService.isSessionActive() ? signOut : signIn} className="link"> | |
| <p> | |
| {userService.isSessionActive() ? `Sign Out`:`Sign In`} | |
| </p> | |
| <p> |
This file contains hidden or 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
| function Header(){ | |
| const items = useSelector(selectItems); | |
| const router = useRouter(); | |
| function signIn(){ | |
| router.push('login'); | |
| } | |
| function signOut(){ | |
| userService.setUserSignOut(); | |
| router.push('/'); |
This file contains hidden or 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
| export const userService = { | |
| // user: userSubject.asObservable(), | |
| userData: {}, | |
| register, | |
| login, | |
| setUserValue, | |
| isSessionActive, | |
| setUserSignOut, | |
| }; | |
| function setUserValue(obj) { userService.userData = obj } |
This file contains hidden or 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
| function onSubmit({ username, password }) { | |
| return userService.login(username, password) | |
| .then((response) => { | |
| // condition: success | |
| }) | |
| .catch(function(error){ | |
| console.log("ERROR HERE: "+error) | |
| setError('apiError', { message: "User Authentication failed" }); | |
| }); | |
| } |
NewerOlder