-
Notifications
You must be signed in to change notification settings - Fork 1
Om corpset #392
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
base: main
Are you sure you want to change the base?
Om corpset #392
Changes from all commits
34c2492
7614067
351a803
dda3184
b8b79a7
ed682b8
0c1a3f6
275cad2
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 |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ const initialValues = { | |
| lactoseFree: false, | ||
| otherFoodPrefs: '', | ||
| email: '', | ||
| contactURL: '', | ||
| mainInstrument: '', | ||
| }; | ||
| type FormValues = typeof initialValues; | ||
|
|
@@ -59,6 +60,7 @@ const AccountPreferences = () => { | |
| lactoseFree: corps.foodPrefs?.lactoseFree ?? false, | ||
| otherFoodPrefs: corps.foodPrefs?.other ?? '', | ||
| email: corps.user.email || undefined, | ||
| contactURL: corps.contactURL ?? '', | ||
| mainInstrument, | ||
| }); | ||
| }, [corps]); | ||
|
|
@@ -86,6 +88,8 @@ const AccountPreferences = () => { | |
| label: i.instrument.name, | ||
| })); | ||
|
|
||
| const isTrivselOmbud = corps?.roles.some(role => role.name === "Trivselombud"); | ||
|
Owner
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. Try to keep the code in English. Although in this case it might be acceptable as we are looking for a role called "Trivselombud". |
||
|
|
||
| return ( | ||
| <form onSubmit={form.onSubmit(handleSubmit)}> | ||
| <FormLoadingOverlay visible={submitting || corpsLoading}> | ||
|
|
@@ -155,6 +159,14 @@ const AccountPreferences = () => { | |
| label={lang('Pronomen', 'Pronouns')} | ||
| {...form.getInputProps('pronouns')} | ||
| /> | ||
| { | ||
| (isTrivselOmbud) && | ||
| (<TextInput | ||
| label={lang('Kontakt URL', 'Contact URL')} | ||
| {...form.getInputProps('contactURL')} | ||
| />) | ||
| } | ||
|
|
||
| </div> | ||
| <div className='flex flex-col gap-2 pl-2'> | ||
| <h3>{lang('Matpreferenser', 'Food preferences')}</h3> | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| import { IconMail } from '@tabler/icons-react'; | ||
| import ActionIcon from 'components/input/action-icon'; | ||
| import { filterNone } from 'utils/array'; | ||
| import { numberAndFullName } from 'utils/corps'; | ||
| import { lang } from 'utils/language'; | ||
|
|
||
| interface Instrument { | ||
| instrument: { name: string }; | ||
| isMainInstrument: boolean; | ||
| } | ||
|
|
||
| interface Role { | ||
| name: string; | ||
| } | ||
|
|
||
| interface Corps { | ||
| id: string; | ||
| firstName: string; | ||
| lastName: string; | ||
| nickName: string | null; | ||
| pronouns: string | null; | ||
| number: number | null; | ||
| bNumber: number | null; | ||
| contactURL: string | null; | ||
| points: number; | ||
| firstGigDate: Date | undefined; | ||
| firstRehearsalDate: Date | undefined; | ||
| instruments: Instrument[]; | ||
| roles: Role[]; | ||
| } | ||
|
|
||
| interface CorpsInfoboxProps { | ||
| corps: Corps; | ||
| } | ||
|
|
||
| const genOtherInstrumentsString = (instruments: string[]) => { | ||
| const instrumentsLower = instruments.map((i) => i.toLowerCase()); | ||
| if (instrumentsLower.length === 0) return ''; | ||
| if (instrumentsLower.length === 1) return instrumentsLower[0] ?? ''; | ||
| return `${instrumentsLower | ||
| .slice(0, instrumentsLower.length - 1) | ||
| .join(', ')} och ${instrumentsLower[instrumentsLower.length - 1] ?? ''}`; | ||
| }; | ||
|
|
||
| const roleToEmail: Record<string, string> = { | ||
| Ordförande: "ordforande@bleckhornen.org", | ||
| ViceOrdförande: "vice@bleckhornen.org", | ||
| Sekreterare: "sekreterare@bleckhornen.org", | ||
| Kassör: "kassor@bleckhornen.org", | ||
| }; | ||
|
|
||
| const roleListToEmail = (roles: Role[]) => { | ||
| const matchingRole = roles.find(r => roleToEmail[r.name]); | ||
|
|
||
| return matchingRole ? ('mailto:' + roleToEmail[matchingRole.name]) : null; | ||
| } | ||
|
|
||
| // A list of "instruments" which should have the prefix "är" | ||
| const beingPrefixes = ['dirigent', 'balett', 'slagverksfröken']; | ||
|
|
||
|
|
||
| const PositionInfobox = ({ corps }: CorpsInfoboxProps) => { | ||
|
Owner
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. I think we should redesign the info card a bit. If we simply use It should be enough to just display the name of the committee, the description, and who is responsible. |
||
| const corpsNameTemp = numberAndFullName(corps); | ||
| const corpsName = | ||
| corpsNameTemp.length > 25 | ||
| ? corpsNameTemp.slice(0, 25) + corpsNameTemp.slice(25).replace(' ', '\n') | ||
| : corpsNameTemp; | ||
|
|
||
| const { | ||
| nickName, | ||
| pronouns, | ||
| contactURL, | ||
| points, | ||
| firstGigDate, | ||
| firstRehearsalDate, | ||
| instruments | ||
| } = corps; | ||
|
|
||
| const mainInstrument = | ||
| instruments.find((i) => i.isMainInstrument)?.instrument.name ?? ''; | ||
| const otherInstruments = instruments | ||
| .filter((i) => !i.isMainInstrument) | ||
| .map((i) => i.instrument.name); | ||
|
|
||
| const isPlayingMainInstrument = !beingPrefixes.includes( | ||
| mainInstrument.toLowerCase(), | ||
| ); | ||
| const isPlayingOtherInstrument = !otherInstruments.some((i) => | ||
| beingPrefixes.includes(i.toLowerCase()), | ||
| ); | ||
|
|
||
|
|
||
| const joinedAt = | ||
| (firstGigDate?.getTime() ?? Number.MAX_VALUE) < | ||
| (firstRehearsalDate?.getTime() ?? Number.MAX_VALUE) | ||
| ? firstGigDate | ||
| : firstRehearsalDate; | ||
|
|
||
| const joinedMsg = `Gick med i corpset den ${joinedAt?.getDate()} ${joinedAt?.toLocaleDateString( | ||
| 'sv', | ||
| { month: 'long' }, | ||
| )} ${joinedAt?.getFullYear()}.`; | ||
|
|
||
| const temp1 = isPlayingMainInstrument ? 'Spelar ' : 'Är '; | ||
|
|
||
| // If the main instrument is the same as the other instruments, we don't need to specify it twice | ||
| const temp2 = | ||
| isPlayingMainInstrument !== isPlayingOtherInstrument | ||
| ? isPlayingOtherInstrument | ||
| ? 'spelar ' | ||
| : 'är ' | ||
| : ''; | ||
|
|
||
| const instrumentsMsg = | ||
| temp1 + | ||
| (otherInstruments.length > 0 ? 'främst ' : '') + | ||
| mainInstrument.toLowerCase() + | ||
| (otherInstruments.length > 0 | ||
| ? ', men ' + temp2 + 'även ' + genOtherInstrumentsString(otherInstruments) | ||
| : '') + | ||
| '.'; | ||
|
|
||
| const roleEmail = roleListToEmail(corps.roles) | ||
| const contact = roleEmail ? roleEmail : contactURL | ||
|
|
||
| return ( | ||
| <div> | ||
| <div className='text-lg font-bold'> | ||
| <div className='flex flex-nowrap items-start gap-2 whitespace-pre'> | ||
| {corpsName} | ||
|
|
||
| {(contact) && ( | ||
| <ActionIcon | ||
| href={contact} | ||
| variant='subtle' | ||
| > | ||
| <IconMail /> | ||
| </ActionIcon> | ||
| )} | ||
| </div> | ||
| {(nickName || pronouns) && ( | ||
| <div className='mb-1 bg-transparent text-xs font-light text-neutral-500'> | ||
| {filterNone([corps.nickName, corps.pronouns]).join(' • ')} | ||
| </div> | ||
| )} | ||
| </div> | ||
| <div className='italic'> | ||
| {lang('Spelpoäng: ', 'Gig points: ')} | ||
| {points} | ||
| </div> | ||
| <div className='h-1.5' /> | ||
| <div className='text-sm font-light'> | ||
| {joinedAt && joinedMsg} {instrumentsMsg}{' '} | ||
|
|
||
| </div> | ||
|
|
||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default PositionInfobox; | ||
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'm still not 100% convinced adding
contactURLtoCorpsis a good idea. I would prefer adding a new modelPositionwhich defines aname,contactUrland maybe links to some of the permission roles.E.g. for the Kassör:
Another solution could be to add
emailandcontactUrltoRole, and create new roles for each board member and commitee chairman. Could be worth addingnameEn/nameEnglishas well to store the English translation.