From 04c6566f3296c55a0941e4728c7cc2755cf3dec2 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Fri, 27 Oct 2023 23:58:20 +0530 Subject: [PATCH 1/9] Configured to make api call to complete payment with received token for payment request. --- client/pages/orders/[orderId].js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/pages/orders/[orderId].js b/client/pages/orders/[orderId].js index 3cf46b1..347ff66 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("/"); + }, + }); 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} ); }; From 91cbbee84550d50df10df35605daaaf1e6117d2b Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 00:38:48 +0530 Subject: [PATCH 2/9] Added two new options in the Header. --- client/components/header.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 }) => { From c56758fda027fafd8b5d545f46926e067158ef32 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 01:01:03 +0530 Subject: [PATCH 3/9] Added orders listing page to list order history of user. --- client/pages/orders/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 client/pages/orders/index.js 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; From 1cfecd5d0e4abc7178e7638731e26e32466d7175 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 01:02:15 +0530 Subject: [PATCH 4/9] Modified the redirection - redirection configured to show orders page after payment success. --- client/pages/orders/[orderId].js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pages/orders/[orderId].js b/client/pages/orders/[orderId].js index 347ff66..de0588a 100644 --- a/client/pages/orders/[orderId].js +++ b/client/pages/orders/[orderId].js @@ -12,7 +12,7 @@ const OrderShow = ({ order, currentUser }) => { orderId: order.id, }, onSuccess: (payment) => { - Router.push("/"); + Router.push("/orders"); }, }); From 9f30b4ce2488fac4ef9cd221b6d6e6ea4d3a5d80 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <87621111+alwinsimon@users.noreply.github.com> Date: Sat, 28 Oct 2023 18:47:10 +0530 Subject: [PATCH 5/9] Create CI - Tests - Auth Service.yml --- .github/workflows/CI - Tests - Auth Service.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/workflows/CI - Tests - Auth Service.yml diff --git a/.github/workflows/CI - Tests - Auth Service.yml b/.github/workflows/CI - Tests - Auth Service.yml new file mode 100644 index 0000000..c98b5ea --- /dev/null +++ b/.github/workflows/CI - Tests - Auth Service.yml @@ -0,0 +1,3 @@ +# ===================================================== Main Branch CI Configuration ===================================================== + +name: CI - Tests - Auth Service From da4fc7b59620a929cd2d2d4db82d062b14f528b8 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 18:58:04 +0530 Subject: [PATCH 6/9] Configured CI Workflow for auth service tests. --- .github/workflows/CI - Tests - Auth Service.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI - Tests - Auth Service.yml b/.github/workflows/CI - Tests - Auth Service.yml index c98b5ea..c33ab5f 100644 --- a/.github/workflows/CI - Tests - Auth Service.yml +++ b/.github/workflows/CI - Tests - Auth Service.yml @@ -1,3 +1,13 @@ -# ===================================================== Main Branch CI Configuration ===================================================== +# ========================================= 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 From 9f78a3a3a1fe8c3a0d37fe1fae6f1b87b264e206 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 19:10:55 +0530 Subject: [PATCH 7/9] Added Test Script for CI Testing. --- auth/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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", From 105be2be8ee9abda2f4773094dbe8e8e189fe4f7 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 19:24:04 +0530 Subject: [PATCH 8/9] Added script for CI Testing. --- orders/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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", From 263f398a4056bdbda796dfa90ca9a28d5633d241 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 19:28:18 +0530 Subject: [PATCH 9/9] Added script for CI Testing. --- payments/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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",