From 1988eac6c7dd3cc924bcbc529197735016923ac7 Mon Sep 17 00:00:00 2001 From: rahihazra <61635387+rahihazra@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:43:19 -0700 Subject: [PATCH] [feat] introduces simple onboarding form (#16) * adds queries to profile table in supabase * adds create profile page * responds to feedback * reruns npm install * makes edits to create profile page --------- Co-authored-by: Pragya Kallanagoudar --- package-lock.json | 34 ++++------------ src/app/create-profile/page.tsx | 70 +++++++++++++++++++++++++++++++++ src/app/profile/page.tsx | 17 ++++---- 3 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 src/app/create-profile/page.tsx diff --git a/package-lock.json b/package-lock.json index a5de1c27..06d5df32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,15 +85,6 @@ "@babel/core": "^7.0.0-0" } }, - "node_modules/@babel/cli/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", - "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, "node_modules/@babel/cli/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -267,15 +258,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/generator/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", - "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, "node_modules/@babel/helper-annotate-as-pure": { "version": "7.22.5", "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.22.5.tgz", @@ -2224,12 +2206,12 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, "node_modules/@next/env": { @@ -3322,9 +3304,9 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" }, "node_modules/core-js-compat": { - "version": "3.33.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.33.0.tgz", - "integrity": "sha512-0w4LcLXsVEuNkIqwjjf9rjCoPhK8uqA4tMRh4Ge26vfLtUutshn+aRJU21I9LCJlh2QQHfisNToLjw1XEJLTWw==", + "version": "3.33.1", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.33.1.tgz", + "integrity": "sha512-6pYKNOgD/j/bkC5xS5IIg6bncid3rfrI42oBH1SQJbsmYPKF7rhzcFzYCcxYMmNQQ0rCEB8WqpW7QHndOggaeQ==", "dependencies": { "browserslist": "^4.22.1" }, diff --git a/src/app/create-profile/page.tsx b/src/app/create-profile/page.tsx new file mode 100644 index 00000000..1796434f --- /dev/null +++ b/src/app/create-profile/page.tsx @@ -0,0 +1,70 @@ +'use client'; + +import { UUID } from 'crypto'; +import { useState } from 'react'; +import { insertProfile } from '../../api/supabase/queries/profiles'; +import { Profile } from '../../types/schema'; +import styles from '../page.module.css'; + +export default function Profile() { + const [firstName, setFirstName] = useState(''); + const [lastName, setLastName] = useState(''); + + const handleInsert = async () => { + if (!firstName || !lastName) return; + const newProfile: Profile = { + // hardcoded values for now + location: 'Berkeley, CA', + user_id: crypto.randomUUID() as UUID, + roles: ['blah'], + languages: ['blah', 'blah'], + hours_per_month: 40, + immigration_law_experience: '5 years', + bar_number: '12345', + start_date: new Date().toDateString(), + interest_ids: [crypto.randomUUID()] as UUID[], + availability_description: 'blah blah blah', + eoir_registered: false, + first_name: firstName, + last_name: lastName, + }; + await insertProfile(newProfile); + setFirstName(''); + setLastName(''); + }; + + return ( +
+
Create Profile Form
+
+
+ +
+
+ +
+ +
+
+ ); +} diff --git a/src/app/profile/page.tsx b/src/app/profile/page.tsx index 9c830f8a..be5a8025 100644 --- a/src/app/profile/page.tsx +++ b/src/app/profile/page.tsx @@ -2,11 +2,7 @@ import 'crypto'; import React, { useEffect, useState } from 'react'; -import { - fetchProfiles, - insertProfile, - updateProfile, -} from '../../api/supabase/queries/profiles'; +import { fetchProfiles } from '../../api/supabase/queries/profiles'; import { Profile } from '../../types/schema'; import styles from '../page.module.css'; @@ -19,6 +15,7 @@ export default function Page() { const allProfiles = await fetchProfiles(); setProfiles(allProfiles); + /** type UUID = `${string}-${string}-${string}-${string}-${string}`; const mockProfile: Profile = { @@ -42,6 +39,7 @@ export default function Page() { await updateProfile(mockProfile.user_id, { hours_per_month: -200, // Update the roles field with new data }); + */ })(); }, []); @@ -62,11 +60,12 @@ export default function Page() {

Languages: {profile.languages.join(', ')}

hoursPerMonth: {profile.hours_per_month}

- immigrationLawExperience: {profile.immigration_law_experience} + immigrationLawExperience:{' '} + {profile.immigration_law_experience.toString()}

-

barNumber: {profile.bar_number}

-

startDate: {profile.start_date}

-

interestIds: {profile.interest_ids}

+

barNumber: {profile.bar_number.toString()}

+

startDate: {profile.start_date.toString()}

+

interestIds: {profile.interest_ids.toString()}

))}