-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Beneficiary to campaign details (#1563)
* Add beneficiary to campaign details page - inital changes * Update beneficiary info * Update organizer info * Update responsive styles * Update Campaign info status * Update responsive styles * Rearrange components * Update beneficiary and organizer wrapper * Update campaign info status --------- Co-authored-by: ani-kalpachka <[email protected]>
- Loading branch information
1 parent
a3cbad1
commit 80b1964
Showing
10 changed files
with
264 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
src/components/client/campaigns/CampaignInfo/CampaignInfo.styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import Image from 'next/image' | ||
|
||
import { styled } from '@mui/material/styles' | ||
import { Button, Stack, Typography } from '@mui/material' | ||
|
||
import theme from 'common/theme' | ||
|
||
export const BeneficiaryOrganizerWrapper = styled(Stack)(() => ({ | ||
marginBottom: theme.spacing(5), | ||
flexDirection: 'column', | ||
justifyContent: 'space-between', | ||
gap: theme.spacing(5), | ||
|
||
[theme.breakpoints.up('md')]: { | ||
flexDirection: 'row', | ||
}, | ||
})) | ||
|
||
export const BeneficiaryOrganizerRoot = styled(Stack)(() => ({ | ||
justifyContent: 'space-between', | ||
flexDirection: 'column', | ||
gap: theme.spacing(3), | ||
width: '100%', | ||
|
||
[theme.breakpoints.up('md')]: { | ||
flexDirection: 'row', | ||
width: '50%', | ||
}, | ||
})) | ||
|
||
export const Avatar = styled(Image)(() => ({ | ||
borderRadius: '50%', | ||
})) | ||
|
||
export const Label = styled(Typography)(() => ({ | ||
fontWeight: 600, | ||
fontSize: theme.spacing(1.6), | ||
margin: 0, | ||
})) | ||
|
||
export const EmailButton = styled(Button)(() => ({ | ||
color: theme.palette.primary.main, | ||
textDecoration: 'underline', | ||
fontSize: theme.spacing(1.75), | ||
padding: 0, | ||
paddingLeft: 2, | ||
|
||
'&:hover': { | ||
backgroundColor: 'unset', | ||
textDecoration: 'underline', | ||
}, | ||
})) | ||
|
||
export const InfoStatusWrapper = styled(Stack)(() => ({ | ||
flexDirection: 'column', | ||
justifyContent: 'space-between', | ||
marginBottom: theme.spacing(6), | ||
|
||
[theme.breakpoints.up('md')]: { | ||
flexDirection: 'row', | ||
gap: theme.spacing(5), | ||
}, | ||
})) | ||
|
||
export const RowWrapper = styled(Stack)(() => ({ | ||
flexDirection: 'row', | ||
})) | ||
|
||
export const StatusLabel = styled(Typography)(() => ({ | ||
fontSize: theme.typography.pxToRem(14), | ||
fontWeight: 700, | ||
marginRight: theme.spacing(1), | ||
})) | ||
|
||
export const StatusText = styled('span')(() => ({ | ||
fontSize: theme.typography.pxToRem(14), | ||
})) | ||
|
||
export const ExpensesButton = styled(Button)(() => ({ | ||
fontSize: theme.typography.pxToRem(14), | ||
justifyContent: 'left', | ||
marginBottom: theme.spacing(1), | ||
})) |
26 changes: 26 additions & 0 deletions
26
src/components/client/campaigns/CampaignInfo/CampaignInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import { CampaignResponse } from 'gql/campaigns' | ||
|
||
import { Grid } from '@mui/material' | ||
|
||
import CampaignInfoBeneficiary from './CampaignInfoBeneficiary' | ||
import CampaignInfoOrganizer from './CampaignInfoOrganizer' | ||
import CampaignInfoStatus from './CampaignInfoStatus' | ||
import { BeneficiaryOrganizerWrapper } from './CampaignInfo.styled' | ||
|
||
type Props = { | ||
campaign: CampaignResponse | ||
showExpensesLink: boolean | ||
} | ||
|
||
export default function CampaignInfo({ campaign }: Props) { | ||
return ( | ||
<Grid mb={5}> | ||
<CampaignInfoStatus showExpensesLink campaign={campaign} /> | ||
<BeneficiaryOrganizerWrapper> | ||
<CampaignInfoBeneficiary campaign={campaign} /> | ||
<CampaignInfoOrganizer campaign={campaign} /> | ||
</BeneficiaryOrganizerWrapper> | ||
</Grid> | ||
) | ||
} |
42 changes: 42 additions & 0 deletions
42
src/components/client/campaigns/CampaignInfo/CampaignInfoBeneficiary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react' | ||
import { CampaignResponse } from 'gql/campaigns' | ||
import { useTranslation } from 'next-i18next' | ||
|
||
import { Stack, Typography } from '@mui/material' | ||
|
||
import { beneficiaryCampaignPictureUrl } from 'common/util/campaignImageUrls' | ||
import { BeneficiaryType } from 'components/admin/beneficiary/BeneficiaryTypes' | ||
|
||
import { Avatar, BeneficiaryOrganizerRoot, Label } from './CampaignInfo.styled' | ||
|
||
type Props = { | ||
campaign: CampaignResponse | ||
} | ||
|
||
export default function CampaignInfoBeneficiary({ campaign }: Props) { | ||
const beneficiaryAvatarSource = beneficiaryCampaignPictureUrl(campaign) | ||
const { t } = useTranslation('campaigns') | ||
|
||
return ( | ||
<BeneficiaryOrganizerRoot> | ||
<Stack direction="column"> | ||
<Label variant="body2">{t('campaign.beneficiary.label')}</Label> | ||
<Typography variant="subtitle2" component="p"> | ||
{campaign.beneficiary.type === BeneficiaryType.individual | ||
? campaign.beneficiary.person?.firstName + ' ' + campaign.beneficiary.person?.lastName | ||
: campaign.beneficiary.company.companyName} | ||
</Typography> | ||
</Stack> | ||
<Avatar | ||
src={beneficiaryAvatarSource} | ||
alt={`${t('campaign.image-of')} ${ | ||
campaign.beneficiary.type === BeneficiaryType.individual | ||
? campaign.beneficiary.person?.firstName + ' ' + campaign.beneficiary.person?.lastName | ||
: campaign.beneficiary.company.companyName | ||
}`} | ||
width={100} | ||
height={100} | ||
/> | ||
</BeneficiaryOrganizerRoot> | ||
) | ||
} |
48 changes: 48 additions & 0 deletions
48
src/components/client/campaigns/CampaignInfo/CampaignInfoOrganizer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react' | ||
import { CampaignResponse } from 'gql/campaigns' | ||
import { useTranslation } from 'next-i18next' | ||
|
||
import { Grid, Stack, Typography } from '@mui/material' | ||
import EmailIcon from '@mui/icons-material/Email' | ||
|
||
import { organizerCampaignPictureUrl } from 'common/util/campaignImageUrls' | ||
|
||
import { Avatar, BeneficiaryOrganizerRoot, EmailButton, Label } from './CampaignInfo.styled' | ||
|
||
type Props = { | ||
campaign: CampaignResponse | ||
} | ||
|
||
export default function CampaignInfoOrganizer({ campaign }: Props) { | ||
const { t } = useTranslation() | ||
const organizerAvatarSource = organizerCampaignPictureUrl(campaign) | ||
|
||
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 || ''} | ||
</Typography> | ||
<EmailButton | ||
startIcon={<EmailIcon color="action" />} | ||
href={ | ||
'mailto:' + | ||
campaign?.organizer?.person.email + | ||
'?subject=Question about: ' + | ||
campaign.title | ||
}> | ||
{campaign?.organizer?.person.email} | ||
</EmailButton> | ||
</Grid> | ||
<Avatar | ||
src={organizerAvatarSource} | ||
alt={`${t('campaign.image-of')} ${campaign.organizer?.person.firstName} ${ | ||
campaign.organizer?.person.lastName | ||
}`} | ||
width={100} | ||
height={100} | ||
/> | ||
</BeneficiaryOrganizerRoot> | ||
) | ||
} |
Oops, something went wrong.