Skip to content

Commit

Permalink
[feat] introduces simple onboarding form (#16)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
rahihazra and Pragya Kallanagoudar authored Oct 24, 2023
1 parent 506e701 commit 1988eac
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 35 deletions.
34 changes: 8 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions src/app/create-profile/page.tsx
Original file line number Diff line number Diff line change
@@ -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<string>('');
const [lastName, setLastName] = useState<string>('');

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 (
<main className={styles.main}>
<div className={styles.description}>Create Profile Form</div>
<form>
<div>
<label htmlFor="firstName">
First Name:
<input
type="text"
name="firstName"
required
value={firstName}
onChange={event => setFirstName(event.target.value)}
/>
</label>
</div>
<div>
<label htmlFor="lastName">
Last Name:
<input
type="text"
name="lastName"
required
value={lastName}
onChange={event => setLastName(event.target.value)}
/>
</label>
</div>
<button type="button" onClick={handleInsert}>
Submit
</button>
</form>
</main>
);
}
17 changes: 8 additions & 9 deletions src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -19,6 +15,7 @@ export default function Page() {
const allProfiles = await fetchProfiles();
setProfiles(allProfiles);

/**
type UUID = `${string}-${string}-${string}-${string}-${string}`;
const mockProfile: Profile = {
Expand All @@ -42,6 +39,7 @@ export default function Page() {
await updateProfile(mockProfile.user_id, {
hours_per_month: -200, // Update the roles field with new data
});
*/
})();
}, []);

Expand All @@ -62,11 +60,12 @@ export default function Page() {
<p>Languages: {profile.languages.join(', ')}</p>
<p>hoursPerMonth: {profile.hours_per_month}</p>
<p>
immigrationLawExperience: {profile.immigration_law_experience}
immigrationLawExperience:{' '}
{profile.immigration_law_experience.toString()}
</p>
<p>barNumber: {profile.bar_number}</p>
<p>startDate: {profile.start_date}</p>
<p>interestIds: {profile.interest_ids}</p>
<p>barNumber: {profile.bar_number.toString()}</p>
<p>startDate: {profile.start_date.toString()}</p>
<p>interestIds: {profile.interest_ids.toString()}</p>
</li>
))}
</ul>
Expand Down

0 comments on commit 1988eac

Please sign in to comment.