-
Notifications
You must be signed in to change notification settings - Fork 18
Add Donation Receipt functionality and UI improvements #2416
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
Changes from all commits
728a21a
3013443
e75accc
0d08f4e
3329fc0
784e637
e28cf6d
4fd7bb5
c5fa70c
25dda11
acd07ad
65e2f27
3aba0e9
48cef18
46304ba
5a07dba
09bcfdb
adc116b
b39983b
b5ef8b2
21360ae
51bc65b
60e1711
fc5d5d4
9c6b64e
188dcf9
98f0051
4b7ba7d
b4c53a8
32ba037
265d220
ed887a3
4c4bbb7
e1721c9
14492d6
89e45fe
6ecefdc
221b40b
6c600d3
fd2cb31
4b6774b
9888ac4
fbdba45
f779501
89c5b45
cf3dd87
344fd68
2596e42
7f0397c
63bea5a
1755930
6389106
06a320a
e774669
8143bba
2bc8d2b
00886ee
e63ad64
ad6193d
c07b965
6592e26
5a608c3
50c063a
508d452
4cd0a1b
b644e3f
09107fc
796ad53
93d2ccb
5d2e8f0
97cefce
3d8345b
280d35a
d829231
33809db
8631e7c
96b5135
1d9075d
48c71e7
980ddcb
e77967d
30c479f
61d2dcf
0c9aed1
7a39e58
03f94a6
a276fae
20b834c
5e44dc3
208fd3b
423c3a1
97f743c
f8f415c
9127bc1
3f3707f
e2ecab7
4561f32
8280303
4187737
2ac4ab0
150bdac
6870132
0d6666c
e9cf2d8
ec62db9
056904f
4e81800
1d34c76
8c90c9e
a77c9f3
01e3638
11711d0
ccb0f5c
80c9dd0
1a4acd8
0202670
5ffa7fd
dbb1aa6
4e1bf48
5d36c11
9177055
642d886
0ceeecb
8e0f077
05d24a2
b0729e0
308076b
c507ab3
35b31d3
bf0114a
ee6a721
ba1b98b
ff7386d
07c060b
e74d954
a3757f5
ce9d262
f1c104e
4e37c1b
7771960
00e21a0
621d635
d1cea41
d434878
47861c3
21222be
633aef2
63e5578
f240c12
3cdcba3
b6392b3
a72da42
f2a148d
ad7bb55
2a572c0
dad4b58
d40be62
e93800e
b611f1c
e4195fa
8048c88
d1931fc
cc2bb26
60acfd6
5afee5c
8664987
fe8ea8f
dd6a36c
d011fba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import type { | ||
GetStaticPaths, | ||
GetStaticProps, | ||
GetStaticPropsContext, | ||
GetStaticPropsResult, | ||
} from 'next'; | ||
import type { AbstractIntlMessages } from 'next-intl'; | ||
import type { Tenant } from '@planet-sdk/common'; | ||
|
||
import Head from 'next/head'; | ||
import { useTranslations } from 'next-intl'; | ||
import UserLayout from '../../../../../../src/features/common/Layout/UserLayout/UserLayout'; | ||
import DonorContactManagement from '../../../../../../src/features/user/DonationReceipt/DonorContactManagement'; | ||
import { | ||
constructPathsForTenantSlug, | ||
getTenantConfig, | ||
} from '../../../../../../src/utils/multiTenancy/helpers'; | ||
import { defaultTenant } from '../../../../../../tenant.config'; | ||
import getMessagesForPage from '../../../../../../src/utils/language/getMessagesForPage'; | ||
|
||
export default function ModifyDonorData() { | ||
const t = useTranslations('DonationReceipt'); | ||
return ( | ||
<UserLayout> | ||
<Head> | ||
<title>{t('donorContactManagement')}</title> | ||
</Head> | ||
<DonorContactManagement /> | ||
</UserLayout> | ||
); | ||
} | ||
|
||
export const getStaticPaths: GetStaticPaths = async () => { | ||
const subDomainPaths = await constructPathsForTenantSlug(); | ||
|
||
const paths = | ||
subDomainPaths?.map((path) => { | ||
return { | ||
params: { | ||
slug: path.params.slug, | ||
locale: 'en', | ||
}, | ||
}; | ||
}) ?? []; | ||
|
||
return { | ||
paths, | ||
fallback: 'blocking', | ||
}; | ||
}; | ||
|
||
interface PageProps { | ||
messages: AbstractIntlMessages; | ||
tenantConfig: Tenant; | ||
} | ||
|
||
export const getStaticProps: GetStaticProps<PageProps> = async ( | ||
context: GetStaticPropsContext | ||
): Promise<GetStaticPropsResult<PageProps>> => { | ||
const tenantConfig = | ||
(await getTenantConfig(context.params?.slug as string)) ?? defaultTenant; | ||
|
||
const messages = await getMessagesForPage({ | ||
locale: context.params?.locale as string, | ||
filenames: ['common', 'me', 'country', 'donationReceipt', 'editProfile'], | ||
}); | ||
|
||
return { | ||
props: { | ||
messages, | ||
tenantConfig, | ||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import type { | ||
GetStaticPaths, | ||
GetStaticProps, | ||
GetStaticPropsContext, | ||
GetStaticPropsResult, | ||
} from 'next'; | ||
import type { Tenant } from '@planet-sdk/common'; | ||
import type { AbstractIntlMessages } from 'next-intl'; | ||
|
||
import { useTranslations } from 'next-intl'; | ||
import Head from 'next/head'; | ||
import UserLayout from '../../../../../../src/features/common/Layout/UserLayout/UserLayout'; | ||
import DonationReceipts from '../../../../../../src/features/user/DonationReceipt/DonationReceipts'; | ||
import { | ||
constructPathsForTenantSlug, | ||
getTenantConfig, | ||
} from '../../../../../../src/utils/multiTenancy/helpers'; | ||
import { defaultTenant } from '../../../../../../tenant.config'; | ||
import getMessagesForPage from '../../../../../../src/utils/language/getMessagesForPage'; | ||
|
||
export default function DonationReceiptsPage() { | ||
const t = useTranslations('DonationReceipt'); | ||
return ( | ||
<UserLayout> | ||
<Head> | ||
<title>{t('receipts')}</title> | ||
</Head> | ||
<DonationReceipts /> | ||
</UserLayout> | ||
); | ||
} | ||
|
||
export const getStaticPaths: GetStaticPaths = async () => { | ||
const subDomainPaths = await constructPathsForTenantSlug(); | ||
|
||
const paths = | ||
subDomainPaths?.map((path) => { | ||
return { | ||
params: { | ||
slug: path.params.slug, | ||
locale: 'en', | ||
}, | ||
}; | ||
}) ?? []; | ||
|
||
return { | ||
paths, | ||
fallback: 'blocking', | ||
}; | ||
}; | ||
|
||
interface PageProps { | ||
messages: AbstractIntlMessages; | ||
tenantConfig: Tenant; | ||
} | ||
|
||
export const getStaticProps: GetStaticProps<PageProps> = async ( | ||
context: GetStaticPropsContext | ||
): Promise<GetStaticPropsResult<PageProps>> => { | ||
const tenantConfig = | ||
(await getTenantConfig(context.params?.slug as string)) ?? defaultTenant; | ||
|
||
const messages = await getMessagesForPage({ | ||
locale: context.params?.locale as string, | ||
filenames: ['common', 'me', 'country', 'donationReceipt'], | ||
}); | ||
|
||
return { | ||
props: { | ||
messages, | ||
tenantConfig, | ||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import type { | ||
GetStaticPaths, | ||
GetStaticProps, | ||
GetStaticPropsContext, | ||
GetStaticPropsResult, | ||
} from 'next'; | ||
import type { Tenant } from '@planet-sdk/common'; | ||
import { useTranslations, type AbstractIntlMessages } from 'next-intl'; | ||
|
||
import Head from 'next/head'; | ||
import UserLayout from '../../../../../../src/features/common/Layout/UserLayout/UserLayout'; | ||
import { | ||
constructPathsForTenantSlug, | ||
getTenantConfig, | ||
} from '../../../../../../src/utils/multiTenancy/helpers'; | ||
import { defaultTenant } from '../../../../../../tenant.config'; | ||
import getMessagesForPage from '../../../../../../src/utils/language/getMessagesForPage'; | ||
import { useTenant } from '../../../../../../src/features/common/Layout/TenantContext'; | ||
import DonationReceiptAuthenticated from '../../../../../../src/features/user/DonationReceipt/DonationReceiptAuthenticated'; | ||
import { useRouter } from 'next/router'; | ||
import { useEffect } from 'react'; | ||
|
||
export default function DonationReceiptPage({ | ||
pageProps: { tenantConfig }, | ||
}: Props) { | ||
const router = useRouter(); | ||
const { setTenantConfig } = useTenant(); | ||
const tReceipt = useTranslations('DonationReceipt'); | ||
|
||
useEffect(() => { | ||
if (router.isReady) setTenantConfig(tenantConfig); | ||
}, [router.isReady]); | ||
|
||
return ( | ||
<UserLayout> | ||
<Head> | ||
<title>{tReceipt('receipts')}</title> | ||
</Head> | ||
<DonationReceiptAuthenticated /> | ||
</UserLayout> | ||
); | ||
} | ||
|
||
export const getStaticPaths: GetStaticPaths = async () => { | ||
const subDomainPaths = await constructPathsForTenantSlug(); | ||
|
||
const paths = | ||
subDomainPaths?.map((path) => { | ||
return { | ||
params: { | ||
slug: path.params.slug, | ||
locale: 'en', | ||
}, | ||
}; | ||
}) ?? []; | ||
|
||
return { | ||
paths, | ||
fallback: 'blocking', | ||
}; | ||
}; | ||
|
||
interface PageProps { | ||
messages: AbstractIntlMessages; | ||
tenantConfig: Tenant; | ||
} | ||
|
||
interface Props { | ||
pageProps: PageProps; | ||
} | ||
|
||
export const getStaticProps: GetStaticProps<PageProps> = async ( | ||
context: GetStaticPropsContext | ||
): Promise<GetStaticPropsResult<PageProps>> => { | ||
const tenantConfig = | ||
(await getTenantConfig(context.params?.slug as string)) ?? defaultTenant; | ||
|
||
const messages = await getMessagesForPage({ | ||
locale: context.params?.locale as string, | ||
filenames: ['common', 'me', 'country', 'donationReceipt'], | ||
}); | ||
|
||
return { | ||
props: { | ||
messages, | ||
tenantConfig, | ||
}, | ||
}; | ||
}; | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,79 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GetStaticPaths, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GetStaticProps, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GetStaticPropsContext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GetStaticPropsResult, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} from 'next'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import type { AbstractIntlMessages } from 'next-intl'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import type { Tenant } from '@planet-sdk/common/build/types/tenant'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useEffect } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useRouter } from 'next/router'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
constructPathsForTenantSlug, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
getTenantConfig, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} from '../../../../src/utils/multiTenancy/helpers'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import getMessagesForPage from '../../../../src/utils/language/getMessagesForPage'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { defaultTenant } from '../../../../tenant.config'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useTenant } from '../../../../src/features/common/Layout/TenantContext'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import DonationReceiptUnauthenticated from '../../../../src/features/user/DonationReceipt/DonationReceiptUnauthenticated'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
interface PageProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
messages: AbstractIntlMessages; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tenantConfig: Tenant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
interface Props { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pageProps: PageProps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export default function DonationReceipt({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pageProps: { tenantConfig }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}: Props) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const router = useRouter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { setTenantConfig } = useTenant(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (router.isReady) setTenantConfig(tenantConfig); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [router.isReady]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return <DonationReceiptUnauthenticated />; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export const getStaticPaths: GetStaticPaths = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const subDomainPaths = await constructPathsForTenantSlug(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const paths = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
subDomainPaths?.map((path) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
params: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
slug: path.params.slug, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
locale: 'en', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) ?? []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
paths, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fallback: 'blocking', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+43
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Make locale handling more dynamic in static paths generation The current implementation hardcodes 'en' as the locale in Consider making the locale dynamic instead of hardcoded: export const getStaticPaths: GetStaticPaths = async () => {
const subDomainPaths = await constructPathsForTenantSlug();
+ const supportedLocales = ['en', 'de', 'es']; // Add your supported locales or fetch them from config
const paths =
subDomainPaths?.map((path) => {
- return {
- params: {
- slug: path.params.slug,
- locale: 'en',
- },
- };
+ return supportedLocales.map((locale) => ({
+ params: {
+ slug: path.params.slug,
+ locale,
+ },
+ }));
- }) ?? [];
+ }).flat() ?? [];
return {
paths,
fallback: 'blocking',
};
}; This creates path combinations for all supported locales and slugs, allowing proper static generation for multiple languages. 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export const getStaticProps: GetStaticProps<PageProps> = async ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context: GetStaticPropsContext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
): Promise<GetStaticPropsResult<PageProps>> => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const tenantConfig = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(await getTenantConfig(context.params?.slug as string)) ?? defaultTenant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const messages = await getMessagesForPage({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
locale: context.params?.locale as string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
filenames: ['common', 'me', 'country', 'donationReceipt'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
messages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tenantConfig, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling to getStaticProps
The function doesn't handle potential errors when fetching tenant config or messages.
Add try/catch blocks and provide fallback values:
📝 Committable suggestion