Started working with PayPal

This commit is contained in:
Tiago Ribeiro
2023-11-24 16:02:55 +00:00
parent 23f2bace5d
commit c312260721
5 changed files with 48 additions and 2 deletions

View File

@@ -14,6 +14,8 @@
"@mdi/js": "^7.1.96",
"@mdi/react": "^1.6.1",
"@next/font": "13.1.6",
"@paypal/paypal-js": "^7.1.0",
"@paypal/react-paypal-js": "^8.1.3",
"@tanstack/react-table": "^8.10.1",
"@types/node": "18.13.0",
"@types/react": "18.0.27",

View File

@@ -9,6 +9,7 @@ import useExamStore from "@/stores/examStore";
import {getExamById} from "@/utils/exams";
import {MODULE_ARRAY, sortByModule, sortByModuleName} from "@/utils/moduleUtils";
import {averageScore, groupBySession} from "@/utils/stats";
import {PayPalButtons} from "@paypal/react-paypal-js";
import clsx from "clsx";
import {capitalize} from "lodash";
import moment from "moment";
@@ -83,6 +84,11 @@ export default function StudentDashboard({user}: Props) {
</span>
</section>
<section className="flex flex-col gap-1 md:gap-3">
<span className="font-bold text-lg">Payment</span>
<PayPalButtons style={{layout: "vertical"}} fundingSource={undefined}></PayPalButtons>
</section>
<section className="flex flex-col gap-1 md:gap-3">
<div className="flex gap-4 items-center">
<div

View File

@@ -10,6 +10,7 @@ import {useRouter} from "next/router";
import {useEffect} from "react";
import useExamStore from "@/stores/examStore";
import usePreferencesStore from "@/stores/preferencesStore";
import {PayPalScriptProvider} from "@paypal/react-paypal-js";
export default function App({Component, pageProps}: AppProps) {
const reset = useExamStore((state) => state.reset);
@@ -31,5 +32,10 @@ export default function App({Component, pageProps}: AppProps) {
}
}, [setIsSidebarMinimized]);
return <Component {...pageProps} />;
return (
<PayPalScriptProvider
options={{clientId: process.env.NEXT_PUBLIC_PAYPAL_CLIENT_ID || "", currency: "EUR", intent: "order", commit: true, vault: true}}>
<Component {...pageProps} />
</PayPalScriptProvider>
);
}

View File

@@ -169,7 +169,7 @@ export default function Home() {
{user.type === "corporate" && <CorporateDashboard user={user} />}
{user.type === "agent" && <AgentDashboard user={user} />}
{user.type === "admin" && <AdminDashboard user={user} />}
{user.type === "developer" && <AdminDashboard user={user} />}
{user.type === "developer" && <StudentDashboard user={user} />}
</Layout>
)}
</>

View File

@@ -885,6 +885,28 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
"@paypal/paypal-js@^7.0.0", "@paypal/paypal-js@^7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@paypal/paypal-js/-/paypal-js-7.1.0.tgz#93effa46dcc9358648ae5d9726550fbc32995461"
integrity sha512-Bp656jfxZF2Q1bz0v+YvA1nO5Tcyb6HmB2Yud+zx4ks5hWi1lLSNPLSaYcwuVJiqrxNs/GWKUOSyVetpzBEbrg==
dependencies:
promise-polyfill "^8.3.0"
"@paypal/react-paypal-js@^8.1.3":
version "8.1.3"
resolved "https://registry.yarnpkg.com/@paypal/react-paypal-js/-/react-paypal-js-8.1.3.tgz#2a46bd864eee02efada370ca50fab5a5bf38f4ff"
integrity sha512-hEm27iYP/UHS3XPBhDdiK2U4PH1FxrOD5O3f9tstAVLJd82l/laCjq751HiESSm63PVOoFeKE41Fe1mYGab+oA==
dependencies:
"@paypal/paypal-js" "^7.0.0"
"@paypal/sdk-constants" "^1.0.122"
"@paypal/sdk-constants@^1.0.122":
version "1.0.133"
resolved "https://registry.yarnpkg.com/@paypal/sdk-constants/-/sdk-constants-1.0.133.tgz#ee65c0bb574554becc8a5d3d0a834a944bbeb0e7"
integrity sha512-NWV0IWrHwQQrNLaUYxQ1GsytvHbDu+x63kRpNJfw1OQeDcUca4B0I4LoBktWQl5gICi090hD56n2Wg08dAl44g==
dependencies:
hi-base32 "^0.5.0"
"@peculiar/asn1-schema@^2.3.6":
version "2.3.6"
resolved "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.3.6.tgz"
@@ -3079,6 +3101,11 @@ hexoid@^1.0.0:
resolved "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz"
integrity sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==
hi-base32@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/hi-base32/-/hi-base32-0.5.1.tgz#1279f2ddae2673219ea5870c2121d2a33132857e"
integrity sha512-EmBBpvdYh/4XxsnUybsPag6VikPYnN30td+vQk+GI3qpahVEG9+gTkG0aXVxTjBqQ5T6ijbWIu77O+C5WFWsnA==
hoist-non-react-statics@^3.3.1:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
@@ -4279,6 +4306,11 @@ primereact@^9.2.3:
"@types/react-transition-group" "^4.4.1"
react-transition-group "^4.4.1"
promise-polyfill@^8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-8.3.0.tgz#9284810268138d103807b11f4e23d5e945a4db63"
integrity sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==
prop-types@15.7.2:
version "15.7.2"
resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz"