From ebeae2201777500e04c37cc5502c11119643f92b Mon Sep 17 00:00:00 2001 From: Alexander Petkov Date: Thu, 4 Apr 2024 19:28:36 +0300 Subject: [PATCH] fix: Show company name if campaign organizer is corporation --- .../admin/campaigns/grid/OrganizerSelect.tsx | 8 +++++-- src/components/admin/donations/grid/Grid.tsx | 1 - src/components/admin/organizers/grid/Grid.tsx | 4 +++- .../CampaignInfo/CampaignInfoOrganizer.tsx | 10 ++++---- src/components/common/person/PersonSelect.tsx | 3 ++- src/gql/campaigns.ts | 23 ++++++++++++++++--- src/gql/person.d.ts | 2 +- 7 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/components/admin/campaigns/grid/OrganizerSelect.tsx b/src/components/admin/campaigns/grid/OrganizerSelect.tsx index dbcc7a14a..7977fb241 100644 --- a/src/components/admin/campaigns/grid/OrganizerSelect.tsx +++ b/src/components/admin/campaigns/grid/OrganizerSelect.tsx @@ -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) => } renderOption={(params, option: OrganizerResponse) => ( - {`${option.person.firstName} ${option.person.lastName}`} + {option.person.company + ? option.person.company.companyName + : `${option.person.firstName} ${option.person.lastName}`} )} isOptionEqualToValue={(option, value) => diff --git a/src/components/admin/donations/grid/Grid.tsx b/src/components/admin/donations/grid/Grid.tsx index 2b2502666..ead4a5fe5 100644 --- a/src/components/admin/donations/grid/Grid.tsx +++ b/src/components/admin/donations/grid/Grid.tsx @@ -96,7 +96,6 @@ export default observer(function Grid() { const { data: { items: donations, total: allDonationsCount } = { items: [], total: 0 }, - error: donationHistoryError, isLoading: isDonationHistoryLoading, refetch, }: UseQueryResult = useDonationsList( diff --git a/src/components/admin/organizers/grid/Grid.tsx b/src/components/admin/organizers/grid/Grid.tsx index ef24bd60a..451c53f76 100644 --- a/src/components/admin/organizers/grid/Grid.tsx +++ b/src/components/admin/organizers/grid/Grid.tsx @@ -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}` }, }, { diff --git a/src/components/client/campaigns/CampaignInfo/CampaignInfoOrganizer.tsx b/src/components/client/campaigns/CampaignInfo/CampaignInfoOrganizer.tsx index d440a6f4a..d330a6de7 100644 --- a/src/components/client/campaigns/CampaignInfo/CampaignInfoOrganizer.tsx +++ b/src/components/client/campaigns/CampaignInfo/CampaignInfoOrganizer.tsx @@ -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 ( - {campaign.organizer?.person.firstName || ''} {campaign.organizer?.person.lastName || ''} + {organizerName} } @@ -37,9 +41,7 @@ export default function CampaignInfoOrganizer({ campaign }: Props) { diff --git a/src/components/common/person/PersonSelect.tsx b/src/components/common/person/PersonSelect.tsx index 1aa6d4ee0..a85780f68 100644 --- a/src/components/common/person/PersonSelect.tsx +++ b/src/components/common/person/PersonSelect.tsx @@ -38,7 +38,8 @@ export default function PersonSelect({ {personList.map((person, index) => ( - {person.firstName} {person.lastName} + {/* {person.firstName} {person.lastName} */} + {person.company ? person.company.companyName : `${person.firstName} ${person.lastName}`} ))} diff --git a/src/gql/campaigns.ts b/src/gql/campaigns.ts index ee22eb531..ee24cf824 100644 --- a/src/gql/campaigns.ts +++ b/src/gql/campaigns.ts @@ -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[] diff --git a/src/gql/person.d.ts b/src/gql/person.d.ts index f4d0e0e3f..6a6bb0609 100644 --- a/src/gql/person.d.ts +++ b/src/gql/person.d.ts @@ -9,7 +9,6 @@ export type PersonResponse = { email?: string phone?: string address: string - company: string createdAt: string newsletter: boolean emailConfirmed: boolean @@ -17,6 +16,7 @@ export type PersonResponse = { coordinators?: PersonRoleResponse organizer?: PersonRoleResponse profileEnabled: boolean + company: Pick } export type PersonRoleResponse = {