Skip to content
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

fix: Show company name if campaign organizer is corporation #1760

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/admin/campaigns/grid/OrganizerSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ export default function OrganizerSelect({ name = 'organizerId', label = 'campaig
options={data || []}
getOptionLabel={(option: OrganizerResponse) => {
if (!option.person) return ''
return `${option.person.firstName} ${option.person.lastName}`
return option.person.company
? option.person.company.companyName
: `${option.person.firstName} ${option.person.lastName}`
}}
renderInput={(params) => <TextField {...params} label={t(label)} />}
renderOption={(params, option: OrganizerResponse) => (
<Box component="li" {...params} key={option.id}>
{`${option.person.firstName} ${option.person.lastName}`}
{option.person.company
? option.person.company.companyName
: `${option.person.firstName} ${option.person.lastName}`}
</Box>
)}
isOptionEqualToValue={(option, value) =>
Expand Down
1 change: 0 additions & 1 deletion src/components/admin/donations/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export default observer(function Grid() {

const {
data: { items: donations, total: allDonationsCount } = { items: [], total: 0 },
error: donationHistoryError,
isLoading: isDonationHistoryLoading,
refetch,
}: UseQueryResult<CampaignDonationHistoryResponse> = useDonationsList(
Expand Down
4 changes: 3 additions & 1 deletion src/components/admin/organizers/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export default observer(function Grid() {
editable: false,
width: 400,
valueGetter: (f) => {
return `${f.row.person.firstName} ${f.row.person.lastName}`
return f.row.person.company
? f.row.person.company.companyName
: `${f.row.person.firstName} ${f.row.person.lastName}`
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ export default function CampaignInfoOrganizer({ campaign }: Props) {
const { t } = useTranslation()
const organizerAvatarSource = organizerCampaignPictureUrl(campaign)

const organizerName = campaign.organizer?.person.company
? campaign.organizer.person.company.companyName
: `${campaign.organizer?.person.firstName} ${campaign.organizer?.person.lastName}`

return (
<BeneficiaryOrganizerRoot>
<Grid>
<Label variant="subtitle2">{t('campaigns:campaign.organizer.name')}</Label>
<Typography variant="subtitle2" component="p">
{campaign.organizer?.person.firstName || ''} {campaign.organizer?.person.lastName || ''}
{organizerName}
</Typography>
<EmailButton
startIcon={<EmailIcon color="action" />}
Expand All @@ -37,9 +41,7 @@ export default function CampaignInfoOrganizer({ campaign }: Props) {
</Grid>
<Avatar
src={organizerAvatarSource}
alt={`${t('campaign.image-of')} ${campaign.organizer?.person.firstName} ${
campaign.organizer?.person.lastName
}`}
alt={`${t('campaign.image-of')} ${organizerName}`}
width={100}
height={100}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/person/PersonInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function PersonInfo({ person }: Props) {
{t('person:info.createdAt')}: {formatDateString(person.createdAt, i18n?.language)}
</Typography>
<Typography>
{t('person:info.company')}: {person.company}
{t('person:info.company')}: {person.company.companyName}
</Typography>
<Typography>
{t('person:info.confirmedEmail')}: {person.emailConfirmed ? 'Yes' : 'No'}
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/person/PersonSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default function PersonSelect({
</MenuItem>
{personList.map((person, index) => (
<MenuItem key={index} value={person.id}>
{person.firstName} {person.lastName}
{/* {person.firstName} {person.lastName} */}
{person.company ? person.company.companyName : `${person.firstName} ${person.lastName}`}
</MenuItem>
))}
</FormTextField>
Expand Down
23 changes: 20 additions & 3 deletions src/gql/campaigns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,33 @@ export type CampaignResponse = BaseCampaignResponse & {
id: UUID
type: BeneficiaryType
publicData: string
person: { id: UUID; firstName: string; lastName: string }
person: {
id: UUID
firstName: string
lastName: string
company: { id: string; companyName: string }
}
company: { id: UUID; companyName: string }
}
coordinator: {
id: UUID
person: { id: UUID; firstName: string; lastName: string; email: string }
person: {
id: UUID
firstName: string
lastName: string
email: string
company: { id: string; companyName: string }
}
}
organizer?: {
id: UUID
person: { id: UUID; firstName: string; lastName: string; email: string }
person: {
id: UUID
firstName: string
lastName: string
email: string
company: { id: string; companyName: string }
}
}
campaignFiles: CampaignFile[] | []
vaults?: VaultResponse[]
Expand Down
2 changes: 1 addition & 1 deletion src/gql/person.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export type PersonResponse = {
email?: string
phone?: string
address: string
company: string
createdAt: string
newsletter: boolean
emailConfirmed: boolean
beneficiaries?: PersonBeneficiaryResponse[]
coordinators?: PersonRoleResponse
organizer?: PersonRoleResponse
profileEnabled: boolean
company: Pick<CompanyResponse, 'id' | 'companyName'>
}

export type PersonRoleResponse = {
Expand Down
Loading