From 40407cec1b90fc71aee9893f2434b67fc435ee3d Mon Sep 17 00:00:00 2001 From: sondrsc Date: Thu, 7 Jul 2022 16:24:16 +0200 Subject: [PATCH 01/14] v0.0.0 --- package.json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 01fcafc..417fb4d 100644 --- a/package.json +++ b/package.json @@ -9,17 +9,17 @@ "lint:fix": "yarn lint --fix" }, "dependencies": { + "@hookform/resolvers": "^2.8.8", "@next-auth/prisma-adapter": "^1.0.1", "@prisma/client": "^3.10.0", - "axios": "^0.26.0", - "@hookform/resolvers": "^2.8.8", "@tailwindcss/forms": "^0.4.0", + "axios": "^0.26.0", "framer-motion": "^6.2.6", - "next": "latest", + "next": "^12.2.0", "next-auth": "^4.2.1", "nodemailer": "^6.7.2", - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react-hook-form": "^7.27.1", "yup": "^0.32.11" }, @@ -33,9 +33,10 @@ "eslint-config-next": "12.0.10", "eslint-config-prettier": "^8.3.0", "postcss-preset-env": "^7.0.1", - "prisma": "^3.10.0", "prettier": "^2.5.1", + "prisma": "^3.10.0", "tailwindcss": "^3.0.18", "typescript": "4.0" - } + }, + "version": "0.0.0" } From 17b4df1a07913df788184250fda3819234dc2998 Mon Sep 17 00:00:00 2001 From: sondrsc Date: Thu, 7 Jul 2022 16:58:31 +0200 Subject: [PATCH 02/14] removing errors --- components/forms/receipt/GroupDropdown.tsx | 26 +- components/forms/receipt/Navigation.tsx | 28 +- package-lock.json | 3129 -------------------- package.json | 2 +- pages/auth/new-user.tsx | 14 +- pages/auth/signin.tsx | 2 +- pages/profile.tsx | 18 +- tsconfig.json | 19 +- 8 files changed, 64 insertions(+), 3174 deletions(-) delete mode 100644 package-lock.json diff --git a/components/forms/receipt/GroupDropdown.tsx b/components/forms/receipt/GroupDropdown.tsx index 278ee6f..5373d16 100644 --- a/components/forms/receipt/GroupDropdown.tsx +++ b/components/forms/receipt/GroupDropdown.tsx @@ -1,12 +1,12 @@ -import { UseFormRegister } from "react-hook-form"; -import { ERROR_MSG_STYLE } from "../styles"; -import { getAllGroups, OnlineGroup } from "./groups"; -import { IReceiptData } from "./state"; +import { UseFormRegister } from 'react-hook-form' +import { ERROR_MSG_STYLE } from '../styles' +import { getAllGroups, OnlineGroup } from './groups' +import { IReceiptData } from './state' type props = { - register: UseFormRegister; - errors?: string; -}; + register: UseFormRegister + errors?: string +} //TODO: Need to fetch the actual groups from OW4 and use them. const GroupDropdown = ({ register, errors }: props) => { @@ -24,14 +24,14 @@ const GroupDropdown = ({ register, errors }: props) => { + Email: + setName(event.target.value)} + value={name} + /> diff --git a/pages/profile/Receipt.tsx b/pages/profile/Receipt.tsx new file mode 100644 index 0000000..425d913 --- /dev/null +++ b/pages/profile/Receipt.tsx @@ -0,0 +1,16 @@ +import React from 'react' + +function Receipt(props) { + return ( +
+
+
{props.tittel}
+
{props.dato}
+
{props.kostnad}
+
{props.status}
+
+
+ ) +} + +export default Receipt diff --git a/pages/profile/ReceiptList.tsx b/pages/profile/ReceiptList.tsx new file mode 100644 index 0000000..aaf83e7 --- /dev/null +++ b/pages/profile/ReceiptList.tsx @@ -0,0 +1,38 @@ +import React from 'react' +import Receipt from './Receipt' + +function ReceiptList() { + return ( +
+

Kvitteringer

+
+
Kvitteringstittel
+
Dato opprettet
+
Beløp
+
Kvitteringsstatus
+
+
+ + + +
+
+ ) +} + +export default ReceiptList From ab8176aec711d2a7bbc84d7ef43f79083e58e301 Mon Sep 17 00:00:00 2001 From: sondrsc Date: Mon, 1 Aug 2022 17:44:37 +0200 Subject: [PATCH 06/14] basic profile design --- pages/index.tsx | 4 +- pages/profile.tsx | 2 + pages/profile/ProfileForm.tsx | 12 ++++-- pages/profile/ProfileMenu.tsx | 79 +++++++++++++++++++++++++++++++++++ pages/profile/Receipt.tsx | 2 +- pages/profile/ReceiptList.tsx | 6 +-- 6 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 pages/profile/ProfileMenu.tsx diff --git a/pages/index.tsx b/pages/index.tsx index 453b9f1..8822af6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -133,6 +133,6 @@ const IndexPage = () => ( -); +) -export default IndexPage; +export default IndexPage diff --git a/pages/profile.tsx b/pages/profile.tsx index 900128c..2b6e8dc 100644 --- a/pages/profile.tsx +++ b/pages/profile.tsx @@ -4,12 +4,14 @@ import Button from '../components/elements/Button' import Layout from '../components/Layout' import ProfileForm from './profile/ProfileForm' +import ProfileMenu from './profile/ProfileMenu' import ReceiptList from './profile/ReceiptList' const Profile = () => { const { data: session, status } = useSession() return ( + {/* diff --git a/pages/profile/ProfileForm.tsx b/pages/profile/ProfileForm.tsx index b82c67d..6c4ecd1 100644 --- a/pages/profile/ProfileForm.tsx +++ b/pages/profile/ProfileForm.tsx @@ -4,10 +4,14 @@ function ProfileForm() { const [name, setName] = useState('') return ( -
-
+
+
-

Endre profilinformasjon

+

Endre profilinformasjon

Navn: Email: setName(event.target.value)} value={name} diff --git a/pages/profile/ProfileMenu.tsx b/pages/profile/ProfileMenu.tsx new file mode 100644 index 0000000..1e1ec7f --- /dev/null +++ b/pages/profile/ProfileMenu.tsx @@ -0,0 +1,79 @@ +import React from 'react' + +function ProfileMenu() { + return ( + + ) +} + +export default ProfileMenu diff --git a/pages/profile/Receipt.tsx b/pages/profile/Receipt.tsx index 425d913..a471b69 100644 --- a/pages/profile/Receipt.tsx +++ b/pages/profile/Receipt.tsx @@ -2,7 +2,7 @@ import React from 'react' function Receipt(props) { return ( -
+
{props.tittel}
{props.dato}
diff --git a/pages/profile/ReceiptList.tsx b/pages/profile/ReceiptList.tsx index aaf83e7..b633311 100644 --- a/pages/profile/ReceiptList.tsx +++ b/pages/profile/ReceiptList.tsx @@ -4,14 +4,14 @@ import Receipt from './Receipt' function ReceiptList() { return (
-

Kvitteringer

-
+

Kvitteringer

+
Kvitteringstittel
Dato opprettet
Beløp
Kvitteringsstatus
-
+
Date: Mon, 1 Aug 2022 21:11:36 +0200 Subject: [PATCH 07/14] minor additions --- pages/auth/signin.tsx | 2 +- pages/profile/ProfileForm.tsx | 12 ++++++++---- pages/profile/ReceiptList.tsx | 14 ++++++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pages/auth/signin.tsx b/pages/auth/signin.tsx index cb10e40..aeaf9ab 100644 --- a/pages/auth/signin.tsx +++ b/pages/auth/signin.tsx @@ -78,7 +78,7 @@ export default function SignIn({ onSubmit={sendLoginVerification} className={`flex flex-col items-center`} > -

Log inn med mail

+

Logg inn med mail

@@ -11,21 +12,24 @@ function ProfileForm() { method="POST" >
-

Endre profilinformasjon

+

Endre profilinformasjon

Navn: setName(event.target.value)} /> Email: setName(event.target.value)} - value={name} + onChange={(event) => setEmail(event.target.value)} /> +
diff --git a/pages/profile/ReceiptList.tsx b/pages/profile/ReceiptList.tsx index b633311..8a09506 100644 --- a/pages/profile/ReceiptList.tsx +++ b/pages/profile/ReceiptList.tsx @@ -3,15 +3,21 @@ import Receipt from './Receipt' function ReceiptList() { return ( -
-

Kvitteringer

-
+
+

+ {' '} + Kvitteringer{' '} +

+
Kvitteringstittel
Dato opprettet
Beløp
Kvitteringsstatus
-
+
Date: Mon, 8 Aug 2022 15:27:18 +0200 Subject: [PATCH 08/14] bug fix --- lib/auth/OnlineProvider.ts | 73 +++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/lib/auth/OnlineProvider.ts b/lib/auth/OnlineProvider.ts index bc752c0..298c35c 100644 --- a/lib/auth/OnlineProvider.ts +++ b/lib/auth/OnlineProvider.ts @@ -1,48 +1,48 @@ -import { Session } from 'next-auth'; -import type { OAuthConfig, OAuthUserConfig } from 'next-auth/providers/oauth'; -import { type } from 'os'; +import { Session } from 'next-auth' +import type { OAuthConfig, OAuthUserConfig } from 'next-auth/providers/oauth' +import { type } from 'os' -export const OW4_ADDRESS = process.env.OW4_ADDRESS || 'https://online.ntnu.no'; +export const OW4_ADDRESS = process.env.OW4_ADDRESS || 'https://online.ntnu.no' export type Token = { - name?: string; - email?: string; - picture?: string; // url to image - accessToken?: string; - iat: number; - exp: number; -}; + name?: string + email?: string + picture?: string // url to image + accessToken?: string + iat: number + exp: number +} export type Account = { - provider: string | null; - type: string | null; - id: number | null; - refreshToken: string | null; - accessToken: string | null; - accessTokenExpires: null; -}; + provider: string | null + type: string | null + id: number | null + refreshToken: string | null + accessToken: string | null + accessTokenExpires: null +} export interface Profile { - sub: number; - name: string; - given_name: string; - family_name: string; - nickname: string; - preferred_username: string; - picture: string; + sub: number + name: string + given_name: string + family_name: string + nickname: string + preferred_username: string + picture: string } interface IOnlinewebScope { - field_of_study: string; - member: boolean; - rfid: string | null; - staff: boolean; - superuser: boolean; + field_of_study: string + member: boolean + rfid: string | null + staff: boolean + superuser: boolean } interface IEmailScope { - email: string; - email_verified: boolean; + email: string + email_verified: boolean } /** @@ -51,9 +51,9 @@ interface IEmailScope { */ export type IAuthProfile = NonNullable & IOnlinewebScope & - Partial; + Partial -export type OnlineSession = Session & {}; +export type OnlineSession = Session & {} // authorization (replaces authorizationUrl, authorizationParams, scope) // token replaces (accessTokenUrl, headers, params) @@ -78,7 +78,7 @@ export default function OnlineProvider

( 'https://old.online.ntnu.no/openid/.well-known/openid-configuration', idToken: true, checks: ['state'], - profile: (profile: IAuthProfile) => { + /*profile: (profile: IAuthProfile) => { return { ...profile, id: '' + profile.sub, @@ -86,6 +86,7 @@ export default function OnlineProvider

( email: profile.email, }; }, + */ options, - }; + } } From 652396bd584bd5e1c9591de9512015ff043f2804 Mon Sep 17 00:00:00 2001 From: Sondre Schirmer-Mikalsen Date: Wed, 14 Sep 2022 19:43:42 +0200 Subject: [PATCH 09/14] navbar added on all pages --- components/Layout/Public/Footer.tsx | 82 ++++++++++++++--------------- pages/_app.tsx | 8 ++- pages/index.tsx | 4 +- pages/kvittering/index.tsx | 7 +-- pages/profile/Receipt.tsx | 2 +- pages/profile/ReceiptList.tsx | 4 +- 6 files changed, 55 insertions(+), 52 deletions(-) diff --git a/components/Layout/Public/Footer.tsx b/components/Layout/Public/Footer.tsx index 2aa7ff5..2083186 100644 --- a/components/Layout/Public/Footer.tsx +++ b/components/Layout/Public/Footer.tsx @@ -1,40 +1,40 @@ -import Link from 'next/link'; -import React from 'react'; +import Link from 'next/link' +import React from 'react' const Footer = () => { return ( -