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

Feature created my campaigns tab #1067

Merged
merged 6 commits into from
Oct 24, 2022
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
6 changes: 6 additions & 0 deletions public/locales/bg/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
"index": "История на сертификати",
"title": "Онлайн дарения"
},
"myCampaigns": {
"index": "Моите кампании",
"history": "Управление на моите кампании",
"noCampaigns": "Вие не сте в роля организатор, координатор или бенефицент към нито една кампания",
"donatedTo": "Кампании, в които съм дарил"
},
"donationsContract": "Договор дарение",
"certificates": "Сертификати",
"birthdateModal": {
Expand Down
6 changes: 6 additions & 0 deletions public/locales/en/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
"index": "Certificate history",
"title": "Online donations"
},
"myCampaigns": {
"index": "My campaigns",
"history": "Manage my campaigns",
"noCampaigns": "You are not in organizer, coordinator or beneficiery role in any campaign",
"donatedTo": "Campaigns I donated to"
},
"donationsContract": "Donation contract",
"certificates": "Certificates",
"birthdateModal": {
Expand Down
15 changes: 15 additions & 0 deletions src/common/hooks/campaigns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ export function useCampaignAdminList() {
)
}

export const useGetUserCampaigns = () => {
const { data: session } = useSession()
return useQuery<AdminCampaignResponse[]>(
endpoints.campaign.getUserCamapaigns.url,
authQueryFnFactory<AdminCampaignResponse[]>(session?.accessToken),
)
}

export function useUserDonationsCampaigns() {
const { data: session } = useSession()
return useQuery<AdminCampaignResponse[]>(endpoints.campaign.getUserDonatedToCampaigns.url, {
queryFn: authQueryFnFactory(session?.accessToken),
})
}

export function useCampaignTypesList() {
return useQuery<CampaignType[]>(endpoints.campaignTypes.listCampaignTypes.url)
}
Expand Down
1 change: 1 addition & 0 deletions src/common/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const routes = {
personalInformation: '/profile/personal-information',
certificates: '/profile/certificates',
contractDonation: '/profile/contract-donation',
myCampaigns: '/profile/my-campaigns',
},
register: '/register',
aboutProject: '/about-project',
Expand Down
67 changes: 67 additions & 0 deletions src/components/auth/profile/MyCampaignsTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { styled } from '@mui/material/styles'
import { Box, Typography } from '@mui/material'
import React from 'react'
import { useTranslation } from 'next-i18next'

import ProfileTab from './ProfileTab'
import { ProfileTabs } from './tabs'
import MyCampaingsTable from './MyCampaignsTable'
import MyDonatedToCampaignTable from './MyDonatedToCampaignsTable'

const PREFIX = 'MyCampaignsTab'

const classes = {
h3: `${PREFIX}-h3`,
thinFont: `${PREFIX}-thinFont`,
smallText: `${PREFIX}-smallText`,
boxTitle: `${PREFIX}-boxTitle`,
}

const Root = styled('div')(({ theme }) => ({
[`& .${classes.h3}`]: {
fontStyle: 'normal',
fontWeight: '500',
fontSize: '25px',
lineHeight: '116.7%',
margin: '0',
},
[`& .${classes.thinFont}`]: {
fontStyle: 'normal',
fontWeight: 400,
fontSize: '24px',
lineHeight: '123.5%',
letterSpacing: '0.25px',
color: '#000000',
margin: 0,
},
[`& .${classes.smallText}`]: {
fontFamily: 'Lato, sans-serif',
fontStyle: 'normal',
fontWeight: '500',
fontSize: '15px',
lineHeight: '160%',
letterSpacing: '0.15px',
},
[`& .${classes.boxTitle}`]: {
backgroundColor: 'white',
padding: theme.spacing(3, 7),
paddingBottom: theme.spacing(3),
marginTop: theme.spacing(3),
boxShadow: theme.shadows[3],
},
}))

export default function MyCampaignsTab() {
const { t } = useTranslation()
return (
<Root>
<MyCampaingsTable />
<Box className={classes.boxTitle}>
<Typography className={classes.h3}>{t('profile:myCampaigns.donatedTo')}</Typography>
</Box>
<ProfileTab name={ProfileTabs.myCampaigns}>
<MyDonatedToCampaignTable />
</ProfileTab>
</Root>
)
}
Loading