Skip to content

Commit

Permalink
fix: Show company name if campaign organizer is corporation
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Apr 4, 2024
1 parent 89e08ff commit ebeae22
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 13 deletions.
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
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

0 comments on commit ebeae22

Please sign in to comment.