diff --git a/.github/workflows/CI - Tests - Auth Service.yml b/.github/workflows/CI - Tests - Auth Service.yml new file mode 100644 index 0000000..c33ab5f --- /dev/null +++ b/.github/workflows/CI - Tests - Auth Service.yml @@ -0,0 +1,13 @@ +# ========================================= Main Branch ::: CI - Tests - Auth Service ========================================= + +name: CI - Tests - Auth Service + +on: pull_request + +jobs: + Production-Branch-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd auth && npm install && npm run test:ci diff --git a/auth/package.json b/auth/package.json index 604068e..b1cfa63 100644 --- a/auth/package.json +++ b/auth/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest", diff --git a/client/components/header.js b/client/components/header.js index b9dac96..77471a3 100644 --- a/client/components/header.js +++ b/client/components/header.js @@ -2,9 +2,11 @@ import Link from "next/link"; export default ({ currentUser }) => { const Links = [ - !currentUser && { label: "Sign Up", href: "auth/signup" }, - !currentUser && { label: "Sign In", href: "auth/signin" }, - currentUser && { label: "Sign Out", href: "auth/signout" }, + !currentUser && { label: "Sign Up", href: "/auth/signup" }, + !currentUser && { label: "Sign In", href: "/auth/signin" }, + currentUser && { label: "Sell Tickets", href: "/tickets/new" }, + currentUser && { label: "My Orders", href: "/orders" }, + currentUser && { label: "Sign Out", href: "/auth/signout" }, ] .filter((validLinks) => validLinks) .map(({ label, href }) => { diff --git a/client/pages/orders/[orderId].js b/client/pages/orders/[orderId].js index 3cf46b1..de0588a 100644 --- a/client/pages/orders/[orderId].js +++ b/client/pages/orders/[orderId].js @@ -1,8 +1,20 @@ import { useEffect, useState } from "react"; +import Router from "next/router"; import StripeCheckout from "react-stripe-checkout"; +import useRequest from "../../hooks/use-request"; const OrderShow = ({ order, currentUser }) => { const [timeLeft, setTimeLeft] = useState(0); + const [makeRequest, errors] = useRequest({ + url: "/api/payments", + method: "post", + body: { + orderId: order.id, + }, + onSuccess: (payment) => { + Router.push("/orders"); + }, + }); useEffect(() => { const findTimeLeft = () => { @@ -33,12 +45,13 @@ const OrderShow = ({ order, currentUser }) => { Time left to complete payment: {timeLeft} seconds. { - console.log(token); + makeRequest({ token: token.id }); }} stripeKey="pk_test_51O53zRSJtuYafghXhYNZzaJqYAh6afqRduQ3UAMs6Wm4vkv30ayq09gBPgU3jYkQPXrofQa9aRbIlb4uuCp3FC6O000J86xaKc" amount={order.ticket.price * 100} email={currentUser.email} /> + {errors} ); }; diff --git a/client/pages/orders/index.js b/client/pages/orders/index.js new file mode 100644 index 0000000..22f886b --- /dev/null +++ b/client/pages/orders/index.js @@ -0,0 +1,23 @@ +const OrderIndex = ({ orders }) => { + return ( + <> + + + ); +}; + +OrderIndex.getInitialProps = async (context, client) => { + const response = await client.get("/api/orders"); + + return { orders: response.data }; +}; + +export default OrderIndex; diff --git a/orders/package.json b/orders/package.json index 010e589..0860052 100644 --- a/orders/package.json +++ b/orders/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest", diff --git a/payments/package.json b/payments/package.json index 71f5232..05529c6 100644 --- a/payments/package.json +++ b/payments/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest",