Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
728a21a
chore: update branch name validation to include 'tax-receipt' prefix
sunilsabatp Jan 21, 2025
3013443
feat: add DonationReceipt page
sunilsabatp Jan 21, 2025
e75accc
feat(UI): add DonationReceiptLayout component with header, data, and …
sunilsabatp Jan 21, 2025
0d08f4e
feat: implement DonationData component for displaying donation record…
sunilsabatp Jan 22, 2025
3329fc0
feat(UI): implement RecipientDetails component for displaying recipie…
sunilsabatp Jan 22, 2025
784e637
feat(UI) : add ReceiptActions(button's) component
sunilsabatp Jan 22, 2025
e28cf6d
fix: minor ui adjustment for mobile view
sunilsabatp Jan 22, 2025
4fd7bb5
feat(UI) : Introduce conditional logic to display a download button …
sunilsabatp Jan 22, 2025
c5fa70c
refactor: rename component to ReceiptListRedirect
sunilsabatp Jan 22, 2025
25dda11
feat(context): Add DonationReceiptContext with provider and custom hook
sunilsabatp Jan 23, 2025
acd07ad
feat(API) : fetch and update donation receipt data based on query par…
sunilsabatp Jan 23, 2025
65e2f27
feat: implement ReceiptListRedirect component with translations and c…
sunilsabatp Jan 23, 2025
3aba0e9
refactor: refactor receipt verification page
sunilsabatp Jan 24, 2025
48cef18
feat: change download button to link element with href for direct fil…
sunilsabatp Jan 24, 2025
46304ba
Merge branch 'tax-receipt/verification-page' into tax-receipt/redirec…
sunilsabatp Jan 24, 2025
5a07dba
feat: add donation-receipts page.
sunilsabatp Jan 24, 2025
09bcfdb
feat: add ModifyUserData page.
sunilsabatp Jan 24, 2025
adc116b
refactor: use verificationDate condition to render download button
sunilsabatp Jan 25, 2025
b39983b
feat: refactor ReceiptData handling and update DonationReceipt compon…
sunilsabatp Jan 27, 2025
b5ef8b2
feat: Implement `putRequest` function
sunilsabatp Jan 27, 2025
21360ae
refactor: move confirmDonorData logic from ReceiptActions to ReceiptD…
sunilsabatp Jan 27, 2025
51bc65b
refactor: rename recipientDetails to donorDetails
sunilsabatp Jan 27, 2025
60e1711
feat: add reusable SCSS mixin for flexible layout management
sunilsabatp Jan 28, 2025
fc5d5d4
refactor: replace donation term with donor
sunilsabatp Jan 28, 2025
9c6b64e
refactor : change the folder name to donor receipt
sunilsabatp Jan 28, 2025
188dcf9
feat(ui): right-align download button for mobile version
sunilsabatp Jan 28, 2025
98f0051
refactor: create a file to store donor receipt type
sunilsabatp Jan 28, 2025
4b7ba7d
feat(ui): minor padding adjustment for mobile view
sunilsabatp Jan 28, 2025
b4c53a8
Merge branch 'tax-receipt/verification-page' into tax-receipt/redirec…
sunilsabatp Jan 28, 2025
32ba037
fix: the import issue
sunilsabatp Jan 28, 2025
265d220
refactor: use term donor instead of user
sunilsabatp Jan 28, 2025
ed887a3
refactor: use mixin flex-layout.
sunilsabatp Jan 28, 2025
4c4bbb7
refactor: rename page and variable
sunilsabatp Jan 29, 2025
e1721c9
feat(ui): add donor contact management layout with header and back bu…
sunilsabatp Jan 29, 2025
14492d6
feat: Add back button logic
sunilsabatp Jan 29, 2025
89e45fe
feat(UI): add text fields for name and address with checkbox and edit…
sunilsabatp Jan 30, 2025
6ecefdc
feat(UI) : add buttons to save data and add new address
sunilsabatp Jan 30, 2025
221b40b
refactor : refactor the donor address form by creating a common FormI…
sunilsabatp Jan 31, 2025
6c600d3
refactor: remove company name filed
sunilsabatp Jan 31, 2025
fd2cb31
feat: integrate address action modals
sunilsabatp Jan 31, 2025
4b6774b
feat: add api to fetch user addresses
sunilsabatp Feb 1, 2025
9888ac4
refactor: move isMatchingAddress to utils, rename, and initialize che…
sunilsabatp Feb 2, 2025
fbdba45
feat: add validation to ensure address is selected before form submis…
sunilsabatp Feb 2, 2025
f779501
feat: handle user profile update and donor address data submission
sunilsabatp Feb 3, 2025
89c5b45
refactor : donor contact form
sunilsabatp Feb 3, 2025
cf3dd87
fix: ensure address selection updates form state and triggers validation
sunilsabatp Feb 3, 2025
344fd68
refactro : refactor confirmDonorData to handle authenticated
sunilsabatp Feb 3, 2025
2596e42
fix : restrict direct access to Donor Contact Management page
sunilsabatp Feb 4, 2025
7f0397c
refactor: simplify condition for authentication check
sunilsabatp Feb 4, 2025
63bea5a
refactor(feedback) : correct import path case for DonationReceipt.mod…
sunilsabatp Feb 4, 2025
1755930
refactor: use the term "donation" instead of "donor."
sunilsabatp Feb 4, 2025
6389106
refactor : rename receiptVerificationHeader to verifyReceiptHeader
sunilsabatp Feb 4, 2025
06a320a
refactor : change the folder name from DonorReceipt to DonationReceipt
sunilsabatp Feb 4, 2025
e774669
refactor: create a new file for donation receipt translation resources
sunilsabatp Feb 4, 2025
8143bba
feat : add receipt verification check for download button
sunilsabatp Feb 4, 2025
2bc8d2b
refactor : remove mixin
sunilsabatp Feb 4, 2025
00886ee
fix: address feedbacks
sunilsabatp Feb 4, 2025
e63ad64
refactor: optimize donor profile update logic and improve state handl…
sunilsabatp Feb 5, 2025
ad6193d
refactor : remove useMemo
sunilsabatp Feb 5, 2025
c07b965
refactor: remove unwanted code
sunilsabatp Feb 6, 2025
6592e26
feat: introduce a toggle to set address as primary
sunilsabatp Feb 7, 2025
5a608c3
feat: add tag to show address type
sunilsabatp Feb 7, 2025
50c063a
refactor : rename state variable
sunilsabatp Feb 7, 2025
508d452
refactor: address feedbacks
sunilsabatp Feb 10, 2025
4cd0a1b
Merge branch 'tax-receipt/verification-page' into tax-receipt/redirec…
sunilsabatp Feb 10, 2025
b644e3f
refactor: remove mixin flex-layout, duplicate code
sunilsabatp Feb 10, 2025
09107fc
Merge branch 'tax-receipt/redirect-receipt-list' into tax-receipt/mod…
sunilsabatp Feb 10, 2025
796ad53
fix: update import statement to match correct file casing for Donatio…
sunilsabatp Feb 10, 2025
93d2ccb
Merge branch 'tax-receipt/redirect-receipt-list' into tax-receipt/mod…
sunilsabatp Feb 10, 2025
5d2e8f0
fix: update import statement to match correct file casing for Donatio…
sunilsabatp Feb 10, 2025
97cefce
feat: add ReceiptValidationError component for invalid receipt cases
sunilsabatp Feb 10, 2025
3d8345b
fix: define types for receipt api data
sunilsabatp Feb 11, 2025
280d35a
refactor: remove unwanted prop
sunilsabatp Feb 11, 2025
d829231
Merge branch 'tax-receipt/verification-page' into tax-receipt/redirec…
sunilsabatp Feb 11, 2025
33809db
Merge branch 'tax-receipt/redirect-receipt-list' into tax-receipt/mod…
sunilsabatp Feb 11, 2025
8631e7c
fix: bugs
sunilsabatp Feb 11, 2025
96b5135
feat: show total donation value.
sunilsabatp Feb 11, 2025
1d9075d
revert: remove unused localization keys in donate.json
mohitb35 Feb 11, 2025
48c71e7
refactor: reorder translation config alphabetically
mohitb35 Feb 11, 2025
980ddcb
refactor: rename donationReceipt.ts --> donationReceiptTypes.ts
mohitb35 Feb 12, 2025
e77967d
fix: remove unintended space in filename
mohitb35 Feb 12, 2025
30c479f
refactor: camelcase localization string
mohitb35 Feb 12, 2025
61d2dcf
feat: refactor ReceiptActions and add error handling
mohitb35 Feb 12, 2025
0c9aed1
Merge branch 'tax-receipt/verification-page' into tax-receipt/total-a…
mohitb35 Feb 12, 2025
7a39e58
Merge pull request #2398 from Plant-for-the-Planet-org/tax-receipt/to…
sunilsabatp Feb 12, 2025
03f94a6
refactor: add explicit null check for address2
sunilsabatp Feb 12, 2025
a276fae
Merge branch 'tax-receipt/verification-page' into tax-receipt/redirec…
sunilsabatp Feb 12, 2025
20b834c
chore: comment out code for future use
sunilsabatp Feb 12, 2025
5e44dc3
Merge pull request #2378 from Plant-for-the-Planet-org/tax-receipt/ve…
mohitb35 Feb 12, 2025
208fd3b
feat: Handle error cases for invalid or missing name/address.
sunilsabatp Feb 13, 2025
423c3a1
Merge branch 'tax-receipt/redirect-receipt-list' into tax-receipt/mod…
sunilsabatp Feb 13, 2025
97f743c
refactor: resolve type error
sunilsabatp Feb 13, 2025
f8f415c
feat: address feedbacks
sunilsabatp Feb 13, 2025
9127bc1
refactor : address feedbacks
sunilsabatp Feb 13, 2025
3f3707f
refactor: rename taxReceiptOverview class to viewTaxReceiptsAction
mohitb35 Feb 13, 2025
e2ecab7
Merge pull request #2380 from Plant-for-the-Planet-org/tax-receipt/re…
sunilsabatp Feb 13, 2025
4561f32
Merge branch 'feature/tax-receipt' into tax-receipt/error-handling
sunilsabatp Feb 13, 2025
8280303
Merge pull request #2401 from Plant-for-the-Planet-org/tax-receipt/er…
sunilsabatp Feb 13, 2025
4187737
feat: preserve donation receipt data during login
sunilsabatp Feb 14, 2025
2ac4ab0
Merge branch 'feature/tax-receipt' into tax-receipt/modify-donor-data…
sunilsabatp Feb 14, 2025
150bdac
Merge branch 'feature/tax-receipt' into tax-receipt/modify-donor-data…
sunilsabatp Feb 14, 2025
6870132
feat(UI): add footer to donation receipt list page
sunilsabatp Feb 14, 2025
0d6666c
fix: corrects invalid import paths for `donationReceiptTypes`
mohitb35 Feb 14, 2025
e9cf2d8
feat(api): fetch donation receipts status from authenticated endpoint
sunilsabatp Feb 14, 2025
ec62db9
refactor: address feedback
sunilsabatp Feb 14, 2025
056904f
refactor: remove unnecessary API call.
sunilsabatp Feb 17, 2025
4e81800
fix(style): properly center-align the donor contact management form
sunilsabatp Feb 17, 2025
1d34c76
refactor: use updateDonationReceiptData instead of setDonationReceip…
sunilsabatp Feb 18, 2025
8c90c9e
fix(style): center-align the download button
sunilsabatp Feb 19, 2025
a77c9f3
Merge branch 'tax-receipt/modify-donor-data-form' of https://github.c…
sunilsabatp Feb 19, 2025
01e3638
Merge branch 'tax-receipt/modify-donor-data-form' into tax-receipt/re…
sunilsabatp Feb 19, 2025
11711d0
feat: add IssuedReceiptCard component for displaying donation receipts
sunilsabatp Feb 19, 2025
ccb0f5c
refactor: extract DonationInfo component for reusability
sunilsabatp Feb 19, 2025
80c9dd0
feat : add UnissuedReceiptCard component
sunilsabatp Feb 19, 2025
1a4acd8
fix: prevent unauthorized users from accessing donor contact management.
sunilsabatp Feb 20, 2025
0202670
refactor: group the translation resources
sunilsabatp Feb 20, 2025
5ffa7fd
fix: refactor DonationReceiptLayout: Extract ErrorMessage component.
sunilsabatp Feb 20, 2025
dbb1aa6
refactor: minor text change
sunilsabatp Feb 20, 2025
4e1bf48
refactor: remove unnecessary code
sunilsabatp Feb 20, 2025
5d36c11
fix : hide primary toggle in edit modal for primary address
sunilsabatp Feb 20, 2025
9177055
fix: allow access to /verify-receipt-data for non-logged-in users
sunilsabatp Feb 20, 2025
642d886
Reengineer tax-receipt code:
jmiridis Feb 21, 2025
0ceeecb
Make DonationReceiptContext persistent and add DebugPanel
jmiridis Feb 23, 2025
8e0f077
fix: check for undefined verification date
sunilsabatp Feb 23, 2025
05d24a2
Merge branch 'tax-receipt/modify-donor-data-form' into tax-receipt/ve…
sunilsabatp Feb 23, 2025
b0729e0
- add validation when DonationReceiptContext is populated
jmiridis Feb 23, 2025
308076b
address the feedback
sunilsabatp Feb 24, 2025
c507ab3
[CodeFactor] Apply fixes
code-factor Feb 24, 2025
35b31d3
address feedback
sunilsabatp Feb 24, 2025
bf0114a
Merge branch 'tax-receipt/modify-donor-data-form' into tax-receipt/ve…
sunilsabatp Feb 24, 2025
ee6a721
refactor: rename `prevState` --> `previousData` for clarity in format…
mohitb35 Feb 24, 2025
ba1b98b
fix: update operation logic to handle verification date more accurately
mohitb35 Feb 24, 2025
ff7386d
Merge branch 'tax-receipt/modify-donor-data-form' into tax-receipt/ve…
mohitb35 Feb 24, 2025
07c060b
address feedback
sunilsabatp Feb 24, 2025
e74d954
refactor: remove the receipt data from session storage after login
sunilsabatp Feb 24, 2025
a3757f5
Merge pull request #2411 from Plant-for-the-Planet-org/tax-receipt/ve…
sunilsabatp Feb 24, 2025
ce9d262
Make 'tin' input field required depending on prop tinIsRequired
jmiridis Feb 24, 2025
f1c104e
Update DonationReceiptContext with updated donor/address and redirect…
jmiridis Feb 24, 2025
4e37c1b
Re-engineer ownership validation to be performed in DonationReceiptWr…
jmiridis Feb 24, 2025
7771960
Re-engineer tinIsRequired out of ReceiptData
jmiridis Feb 25, 2025
00e21a0
Merge branch 'tax-receipt/modify-donor-data-form' into tax-receipt/re…
sunilsabatp Feb 25, 2025
621d635
Merge branch 'tax-receipt/modify-donor-data-form' into tax-receipt/re…
sunilsabatp Feb 25, 2025
d1cea41
chore: remove console log
sunilsabatp Feb 25, 2025
d434878
fix: minor ui adjustment
sunilsabatp Feb 25, 2025
47861c3
feat: add ReceiptVerificationErrors component to display error messages
sunilsabatp Feb 25, 2025
21222be
feat: add ownership validation and improve profile update logic in Do…
sunilsabatp Feb 25, 2025
633aef2
feat: add pending receipt badge
sunilsabatp Feb 25, 2025
63e5578
feat: add popover to display reference and payment date for multiple …
sunilsabatp Feb 25, 2025
f240c12
feat: restore "View All Tax Receipts" section in the footer
sunilsabatp Feb 25, 2025
3cdcba3
fix: minor ui fixes for receipt list page
sunilsabatp Feb 25, 2025
b6392b3
feat: render TIN text field if TIN is present in the receipt
sunilsabatp Feb 26, 2025
a72da42
fix: clear session storage if receipt does not belong to the owner
sunilsabatp Feb 26, 2025
f2a148d
refactor: remove unwanted code, formatted type imports
sunilsabatp Feb 26, 2025
ad7bb55
feat: display address limit message and hide add button when max limi…
sunilsabatp Feb 26, 2025
2a572c0
fix: receipt issuance
sunilsabatp Feb 26, 2025
dad4b58
fix: use next link instead of <a> for navigation
sunilsabatp Feb 26, 2025
d40be62
fix: prevent rendering unauthorized error component for receipt issu…
sunilsabatp Feb 26, 2025
e93800e
fix: handle empty donation receipts case
sunilsabatp Feb 27, 2025
b611f1c
fix: send donation UIDs as a comma-separated string
sunilsabatp Feb 27, 2025
e4195fa
feat: add loading state to receipt card button
sunilsabatp Feb 27, 2025
8048c88
fix: convert the email id's to lower case
sunilsabatp Feb 27, 2025
d1931fc
refactor: minor text change
sunilsabatp Feb 28, 2025
cc2bb26
fix: ensure number format always has 2 decimals
sunilsabatp Feb 28, 2025
60acfd6
fix(verify-page): ensure number format always has 2 decimals
sunilsabatp Feb 28, 2025
5afee5c
fix : resolve locale issue
sunilsabatp Feb 28, 2025
8664987
fix : minor ui updates, provide missing dependency
sunilsabatp Feb 28, 2025
fe8ea8f
refactor: remove any type
sunilsabatp Feb 28, 2025
dd6a36c
feat: remove the unwanted dependency
sunilsabatp Feb 28, 2025
d011fba
fix: explicitly check for null in addressGuid condition to determine …
sunilsabatp Feb 28, 2025
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
5 changes: 5 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/consistent-type-imports */

// Use type safe message keys with `next-intl`
type MessagesAllProjects =
typeof import('./public/static/locales/en/allProjects.json');
Expand All @@ -8,6 +10,8 @@ type MessagesCountry = typeof import('./public/static/locales/en/country.json');
type MessagesDonate = typeof import('./public/static/locales/en/donate.json');
type MessagesDonationLink =
typeof import('./public/static/locales/en/donationLink.json');
type MessagesDonationReceipt =
typeof import('./public/static/locales/en/donationReceipt.json');
type MessagesEditProfile =
typeof import('./public/static/locales/en/editProfile.json');
type MessagesGiftfunds =
Expand Down Expand Up @@ -42,6 +46,7 @@ type Messages = MessagesAllProjects &
MessagesCountry &
MessagesDonate &
MessagesDonationLink &
MessagesDonationReceipt &
MessagesEditProfile &
MessagesGiftfunds &
MessagesLeaderboard &
Expand Down
4 changes: 4 additions & 0 deletions i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default getRequestConfig(async ({ locale }) => {
...(await import(`./public/static/locales/${locale}/donate.json`)).default,
...(await import(`./public/static/locales/${locale}/donationLink.json`))
.default,
...(await import(`./public/static/locales/${locale}/donationReceipt.json`))
.default,
...(await import(`./public/static/locales/${locale}/editProfile.json`))
.default,
...(await import(`./public/static/locales/${locale}/giftfunds.json`))
Expand Down Expand Up @@ -50,6 +52,8 @@ export default getRequestConfig(async ({ locale }) => {
...(await import(`./public/static/locales/en/country.json`)).default,
...(await import(`./public/static/locales/en/donate.json`)).default,
...(await import(`./public/static/locales/en/donationLink.json`)).default,
...(await import(`./public/static/locales/en/donationReceipt.json`))
.default,
...(await import(`./public/static/locales/en/editProfile.json`)).default,
...(await import(`./public/static/locales/en/giftfunds.json`)).default,
...(await import(`./public/static/locales/en/leaderboard.json`)).default,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "node ./husky-prepare.js"
},
"validate-branch-name": {
"pattern": "^(main|develop){1}$|^(feature|hotfix|address-mgmt)/[a-z0-9-_]+$",
"pattern": "^(main|develop){1}$|^(feature|hotfix|tax-receipt)/[a-z0-9-_]+$",
"errorMsg": "Invalid branch name. \n 1.Branch names can contain lowercase characters, numbers, hyphen and underscore. \n 2.Except for 'main' and 'develop', branch names must begin with 'feature/' or 'hotfix/' "
},
"engines": {
Expand Down
15 changes: 9 additions & 6 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
getTenantSlug,
} from '../src/utils/multiTenancy/helpers';
import { NextIntlClientProvider } from 'next-intl';
import { DonationReceiptProvider } from '../src/features/common/Layout/DonationReceiptContext';

const VideoContainer = dynamic(
() => import('../src/features/common/LandingVideo'),
Expand Down Expand Up @@ -144,30 +145,30 @@
isMobile: boolean;
};

const PlanetWeb = ({
Component,
pageProps,
emotionCache = clientSideEmotionCache,
}: AppPropsWithLayout) => {
const router = useRouter();
const [isMap, setIsMap] = React.useState(false);
const [currencyCode, setCurrencyCode] = React.useState('');
const [browserCompatible, setBrowserCompatible] = React.useState(false);

const { tenantConfig } = pageProps;

const tagManagerArgs = {
gtmId: process.env.NEXT_PUBLIC_GA_TRACKING_ID,
};

if (process.env.NODE_ENV !== 'production') {
if (process.env.VERCEL_URL && typeof window !== 'undefined') {
if (process.env.VERCEL_URL !== window.location.hostname) {
router.replace(`https://${process.env.VERCEL_URL}`);
}
}
}

Check notice on line 171 in pages/_app.tsx

View check run for this annotation

codefactor.io / CodeFactor

pages/_app.tsx#L148-L171

Complex Method
React.useEffect(() => {
storeConfig(tenantConfig);
}, []);
Expand Down Expand Up @@ -302,12 +303,14 @@
<ProjectPropsProvider>
<BulkCodeProvider>
<AnalyticsProvider>
{isMap ? (
<MapHolder
setshowVideo={setshowVideo}
/>
) : null}
{pageContent}
<DonationReceiptProvider>
{isMap ? (
<MapHolder
setshowVideo={setshowVideo}
/>
) : null}
{pageContent}
</DonationReceiptProvider>
</AnalyticsProvider>
</BulkCodeProvider>
</ProjectPropsProvider>
Expand Down
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,
},
};
};
74 changes: 74 additions & 0 deletions pages/sites/[slug]/[locale]/profile/donation-receipt/index.tsx
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,
},
};
};
89 changes: 89 additions & 0 deletions pages/sites/[slug]/[locale]/profile/donation-receipt/verify.tsx
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,
},
};
};
Comment on lines +72 to +89
Copy link
Contributor

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:

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'],
-  });
+  try {
+    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,
+      },
+    };
+  } catch (error) {
+    console.error('Error in getStaticProps:', error);
+    return {
+      notFound: true,
+    };
+  }
-  return {
-    props: {
-      messages,
-      tenantConfig,
-    },
-  };
};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

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,
},
};
};
export const getStaticProps: GetStaticProps<PageProps> = async (
context: GetStaticPropsContext
): Promise<GetStaticPropsResult<PageProps>> => {
try {
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,
},
};
} catch (error) {
console.error('Error in getStaticProps:', error);
return {
notFound: true,
};
}
};

79 changes: 79 additions & 0 deletions pages/sites/[slug]/[locale]/verify-receipt-data.tsx
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 getStaticPaths, which limits internationalization flexibility.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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',
};
};
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 supportedLocales.map((locale) => ({
params: {
slug: path.params.slug,
locale,
},
}));
}).flat() ?? [];
return {
paths,
fallback: 'blocking',
};
};


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,
},
};
};
Loading
Loading