Skip to content

Commit

Permalink
Merge pull request #243 from alwinsimon/v1
Browse files Browse the repository at this point in the history
V1
  • Loading branch information
alwinsimon authored Oct 28, 2023
2 parents c004a94 + f837454 commit 4b75fc8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/CI - Tests - Auth Service.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions client/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
15 changes: 14 additions & 1 deletion client/pages/orders/[orderId].js
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down Expand Up @@ -33,12 +45,13 @@ const OrderShow = ({ order, currentUser }) => {
Time left to complete payment: {timeLeft} seconds.
<StripeCheckout
token={(token) => {
console.log(token);
makeRequest({ token: token.id });
}}
stripeKey="pk_test_51O53zRSJtuYafghXhYNZzaJqYAh6afqRduQ3UAMs6Wm4vkv30ayq09gBPgU3jYkQPXrofQa9aRbIlb4uuCp3FC6O000J86xaKc"
amount={order.ticket.price * 100}
email={currentUser.email}
/>
{errors}
</div>
);
};
Expand Down
23 changes: 23 additions & 0 deletions client/pages/orders/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const OrderIndex = ({ orders }) => {
return (
<>
<ul>
{orders.map((order) => {
return (
<li key={orders.id}>
{order.ticket.title} - {order.status}
</li>
);
})}
</ul>
</>
);
};

OrderIndex.getInitialProps = async (context, client) => {
const response = await client.get("/api/orders");

return { orders: response.data };
};

export default OrderIndex;
3 changes: 2 additions & 1 deletion orders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion payments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4b75fc8

Please sign in to comment.