-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] create the profile context #24
Changes from all commits
41201f3
08a3545
a799072
b76c698
1921cf8
258d8c0
2f9b8ab
72ddac6
8704604
1f9cc70
96e315b
e0cc58d
41bb89b
57fb90b
5caadc4
d461ca4
ceed721
20fa743
a2df6d7
1e8f9f7
189f444
850dc4f
ffb2b73
87f92fd
58bb001
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import BPLogo from '@/assets/images/bp-logo.png'; | ||
import { Container, Image } from './page.style'; | ||
import OnboardingFlow from './onboarding/page'; | ||
import { Container } from './page.style'; | ||
|
||
export default function Home() { | ||
return ( | ||
<Container> | ||
<Image src={BPLogo} alt="Blueprint Logo" /> | ||
<p>Open up app/page.tsx to get started!</p> | ||
<OnboardingFlow /> | ||
</Container> | ||
kevin3656 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useState } from 'react'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this file carried over from the 1st sprint? if so, we may have to remove this file. (see above comment about removing useProfile from the |
||
import { Profile } from '../types/schema'; | ||
|
||
const initialProfiles: Profile[] = []; | ||
|
||
export const useProfile = () => { | ||
const [profiles, setProfiles] = useState<Profile[]>(initialProfiles); | ||
|
||
const addProfile = (newProfile: Profile) => { | ||
setProfiles(prev => [...prev, newProfile]); | ||
}; | ||
|
||
const updateProfile = (index: number, updates: Partial<Profile>) => { | ||
setProfiles(prev => | ||
prev.map((profile, i) => | ||
i === index ? { ...profile, ...updates } : profile, | ||
), | ||
); | ||
}; | ||
|
||
const removeProfile = (index: number) => { | ||
setProfiles(prev => prev.filter((_, i) => i !== index)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hehe can you write a comment explaining what's going on here |
||
}; | ||
|
||
return { | ||
profiles, | ||
addProfile, | ||
updateProfile, | ||
removeProfile, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if you can move the heading out of this component and just put it in the retuned HTML? since it's present in every step of this flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo yeah i think it might be cleaner to make these reusable components, which take in the props:
But that change can be included in the next sprint! Also, since we're hardcoding the value and options to be strings, this structure might only work for StateSelection and GardenTypeSelection, but not PlotSelection? (unless we pass in an optional
optionValues?: boolean[]
prop?)But even then we also have to map the values of
states
to all caps, (i.e. it should be 'TENNESSEE' in the db) andgardenTypes
toUserTypeEnum
where
export type UserTypeEnum = 'INDIV' | 'SCHOOL' | 'ORG';
should be in the schema