-
Notifications
You must be signed in to change notification settings - Fork 39
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
Kolonka "Prostředí" může nabývat vícero hodnot #1128
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -19,24 +19,25 @@ export const OccupationSelect = ({ | |
"looking-for-job": "Hledám práci", | ||
"other": "Jiné", | ||
}; | ||
const occupationSet = new Set(decodeSelection(occupation)); | ||
|
||
return ( | ||
<div> | ||
<label className="mb-1 block">V jakém prostředí se pohybuješ?</label> | ||
<p className="typo-caption mb-3"> | ||
Pokud toho děláš víc, vyber, co převažuje. | ||
Pokud toho děláš víc, klidně vyber více možností. | ||
</p> | ||
|
||
<div> | ||
{Object.entries(options).map(([id, label]) => ( | ||
<label key={id} className="mb-1 flex items-center"> | ||
<input | ||
type="radio" | ||
type="checkbox" | ||
className="mr-3" | ||
name="occupation" | ||
disabled={disabled} | ||
checked={occupation === id} | ||
onChange={() => onChange(id)} | ||
checked={occupationSet.has(id)} | ||
onChange={() => onChange(encodeSelection(occupationSet, id))} | ||
/> | ||
<span>{label}</span> | ||
</label> | ||
|
@@ -45,3 +46,15 @@ export const OccupationSelect = ({ | |
</div> | ||
); | ||
}; | ||
|
||
const encodeSelection = (occupation: Set<string>, id: string) => { | ||
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. Chvilku jsem tady bádal nad tím, jestli nemít samostatně něco jako 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. Jakože 2 obecný funkce?
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. Přesně tak. Když pak budu číst |
||
if (occupation.has(id)) { | ||
occupation.delete(id); | ||
} else { | ||
occupation.add(id); | ||
} | ||
return Array.from(occupation).join("; "); | ||
}; | ||
|
||
const decodeSelection = (occupation?: string) => | ||
occupation?.split(/;\s*/).filter((s) => s !== ""); |
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.
Navrhuju ještě v rámci téhle změny zrušit možnost Jiné, s těmi checkboxy už mně definitivně nedává smysl :) V databázi projdu a zahodím.
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.
Smáznu.