From c932b45be8fcd6135f2d3c78368a0cb1d514029e Mon Sep 17 00:00:00 2001 From: Dzhani Ivanov <68897146+dzhaniivanov@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:29:45 +0300 Subject: [PATCH 01/57] [#1554] headings font size bug fixes (#1613) * headings font size bug fixes * removed library from package.json --- public/locales/bg/campaigns.json | 2 +- public/locales/en/campaigns.json | 2 +- src/components/client/campaigns/CampaignNewsSection.tsx | 2 +- src/components/client/campaigns/DonationWishes.tsx | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/public/locales/bg/campaigns.json b/public/locales/bg/campaigns.json index 1af1f4bf1..84667c8e0 100644 --- a/public/locales/bg/campaigns.json +++ b/public/locales/bg/campaigns.json @@ -107,7 +107,7 @@ "others": "други", "profile": "Профил:", "status": "Статус:", - "messages": "Кампанията подкрепиха:", + "messages": "Кампанията подкрепиха", "sort": { "title": "Сортирай по:", "date": "Дата", diff --git a/public/locales/en/campaigns.json b/public/locales/en/campaigns.json index 078e494be..7c347ac37 100644 --- a/public/locales/en/campaigns.json +++ b/public/locales/en/campaigns.json @@ -88,7 +88,7 @@ "documents": "documents", "guarantor": "guarantor", "others": "others", - "messages": "Messages:", + "messages": "Messages", "sort": { "title": "Sort by:", "date": "Date", diff --git a/src/components/client/campaigns/CampaignNewsSection.tsx b/src/components/client/campaigns/CampaignNewsSection.tsx index 7d5db21b6..ee879f885 100644 --- a/src/components/client/campaigns/CampaignNewsSection.tsx +++ b/src/components/client/campaigns/CampaignNewsSection.tsx @@ -163,7 +163,7 @@ export default function CampaignNewsSection({ campaign, canCreateArticle }: Prop return ( - + {t('news')} {canCreateArticle && ( diff --git a/src/components/client/campaigns/DonationWishes.tsx b/src/components/client/campaigns/DonationWishes.tsx index e69af4bec..197634018 100644 --- a/src/components/client/campaigns/DonationWishes.tsx +++ b/src/components/client/campaigns/DonationWishes.tsx @@ -95,9 +95,10 @@ export default function DonationWishes({ campaignId, pageSize = 5 }: Props) { {t('campaign.messages')} From 3a25e00c47bac36e60e72c239d083eba23f23adf Mon Sep 17 00:00:00 2001 From: RalitsaIlieva Date: Thu, 12 Oct 2023 09:23:14 +0200 Subject: [PATCH 02/57] Terms and GDPR added in the registerForm (#1617) * Terms and GDPR added in the registerForm * Format check added * Some error messages added in the RegisterForm --- README.md | 2 + public/locales/bg/auth.json | 1 + public/locales/en/auth.json | 1 + src/common/form/validation.ts | 2 + .../one-time-donation/RegisterDialog.tsx | 40 +++++++++++++++++-- .../client/one-time-donation/Steps.tsx | 4 ++ .../helpers/validation-schema.ts | 4 ++ src/gql/donations.d.ts | 4 ++ 8 files changed, 54 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1a25cd68c..f7b857938 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates: ## Contributors ✨ + [![All Contributors](https://img.shields.io/badge/all_contributors-73-orange.svg?style=flat-square)](#contributors-) + Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for: diff --git a/public/locales/bg/auth.json b/public/locales/bg/auth.json index de309d026..fd2880268 100644 --- a/public/locales/bg/auth.json +++ b/public/locales/bg/auth.json @@ -2,6 +2,7 @@ "alerts": { "welcome": "Добре дошли!", "invalid-login": "Грешен потребител / парола.", + "register-error": "Моля, попълнете необходимата информация", "duplicate-email": "Потребител с такъв имейл вече съществува", "re-login": "Моля, влезте отново в профила си.", "forgotten-password-error": "Потребителя не е намерен, моля опитайте отново!", diff --git a/public/locales/en/auth.json b/public/locales/en/auth.json index 88246118b..d03645475 100644 --- a/public/locales/en/auth.json +++ b/public/locales/en/auth.json @@ -2,6 +2,7 @@ "alerts": { "welcome": "Welcome!", "invalid-login": "Wrong username / password.", + "register-error": "Please, fill in the necessary information", "re-login": "Please login into your account.", "forgotten-password-error": "User not found, please try again!", "forgotten-password-success": "Please check your email!", diff --git a/src/common/form/validation.ts b/src/common/form/validation.ts index 40c4ec54f..9de30a63e 100644 --- a/src/common/form/validation.ts +++ b/src/common/form/validation.ts @@ -44,6 +44,8 @@ export const customValidators = { phone: () => ({ key: 'validation:phone' }), name: () => ({ key: 'validation:invalid' }), paymentRef: () => ({ key: 'validation:payment-reference' }), + terms: () => ({ key: 'validation:terms-of-use' }), + gdpr: () => ({ key: 'validation:terms-of-service' }), } setLocale({ diff --git a/src/components/client/one-time-donation/RegisterDialog.tsx b/src/components/client/one-time-donation/RegisterDialog.tsx index c100f111d..d1f0dab29 100644 --- a/src/components/client/one-time-donation/RegisterDialog.tsx +++ b/src/components/client/one-time-donation/RegisterDialog.tsx @@ -1,4 +1,4 @@ -import { Button, CircularProgress, Grid, Typography } from '@mui/material' +import { Button, CircularProgress, FormHelperText, Grid, Typography } from '@mui/material' import React, { useContext, useState } from 'react' import { signIn } from 'next-auth/react' import { useTranslation } from 'next-i18next' @@ -12,6 +12,9 @@ import { useFormikContext } from 'formik' import { OneTimeDonation } from 'gql/donations' import { RegisterFormData } from 'components/client/auth/register/RegisterForm' import { StepsContext } from './helpers/stepperContext' +import AcceptPrivacyPolicyField from 'components/common/form/AcceptPrivacyPolicyField' +import AcceptTermsField from 'components/common/form/AcceptTermsField' +import AcceptNewsLetterField from 'components/common/form/AcceptNewsletterField' export default function RegisterForm() { const { t } = useTranslation() @@ -28,13 +31,22 @@ export default function RegisterForm() { confirmPassword: formik.values.confirmPassword as string, terms: formik.values.terms as boolean, gdpr: formik.values.gdpr as boolean, + newsletter: formik.values.newsletter as boolean, } const onClick = async () => { try { setLoading(true) - // Register in Keycloak - await register(values) + + if (values.terms && values.gdpr && values.password === values.confirmPassword) { + await register(values) + } else if (!values.terms) { + throw new Error('Terms not accepted') + } else if (!values.gdpr) { + throw new Error('GDPR not accepted') + } else { + throw new Error('Confirm password doesn`t match') + } // Authenticate const resp = await signIn<'credentials'>('credentials', { @@ -42,6 +54,7 @@ export default function RegisterForm() { password: values.password, redirect: false, }) + if (resp?.error) { throw new Error(resp.error) } @@ -54,7 +67,7 @@ export default function RegisterForm() { } catch (error) { console.error(error) setLoading(false) - AlertStore.show(t('auth:alerts.invalid-login'), 'error') + AlertStore.show(t('auth:alerts.register-error'), 'error') } } @@ -92,6 +105,25 @@ export default function RegisterForm() { label="auth:account.confirm-password" autoComplete="new-password" /> + {formik.values.registerPassword !== formik.values.confirmPassword && + formik.touched.confirmPassword && ( + + {t('validation:password-match')} + + )} + + + + {!formik.values.terms && formik.touched.terms && ( + {t('validation:terms-of-use')} + )} + + {!formik.values.gdpr && formik.touched.gdpr && ( + + {t('validation:terms-of-service')} + + )} + + ), }, @@ -110,7 +110,7 @@ export default function CampaignNewsGrid() { return ( ) @@ -126,7 +126,7 @@ export default function CampaignNewsGrid() { if (!params.row.editedAt) return '' return ( - + ) }, diff --git a/src/components/admin/campaigns/grid/BeneficiarySelect.tsx b/src/components/admin/campaigns/grid/BeneficiarySelect.tsx index 3a5c50643..79acfcb55 100644 --- a/src/components/admin/campaigns/grid/BeneficiarySelect.tsx +++ b/src/components/admin/campaigns/grid/BeneficiarySelect.tsx @@ -3,7 +3,7 @@ import { TranslatableField, translateError } from 'common/form/validation' import { useField } from 'formik' import { BeneficiaryListResponse } from 'gql/beneficiary' import { useState } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { useBeneficiariesList } from 'service/beneficiary' export default function BeneficiarySelect({ name = 'beneficiaryId' }) { diff --git a/src/components/admin/campaigns/grid/CampaignGrid.tsx b/src/components/admin/campaigns/grid/CampaignGrid.tsx index a04c07f87..6d2c7c993 100644 --- a/src/components/admin/campaigns/grid/CampaignGrid.tsx +++ b/src/components/admin/campaigns/grid/CampaignGrid.tsx @@ -227,7 +227,7 @@ export default function CampaignGrid() { renderCell: (cellValues: GridRenderCellParams) => ( ), @@ -240,7 +240,7 @@ export default function CampaignGrid() { headerAlign: 'left', renderCell: (cellValues: GridRenderCellParams) => ( - + ), }, @@ -253,7 +253,7 @@ export default function CampaignGrid() { renderCell: (cellValues: GridRenderCellParams) => ( ), @@ -267,7 +267,7 @@ export default function CampaignGrid() { renderCell: (cellValues: GridRenderCellParams) => ( ), diff --git a/src/components/admin/campaigns/grid/CoordinatorSelect.tsx b/src/components/admin/campaigns/grid/CoordinatorSelect.tsx index f6c906762..11629dd77 100644 --- a/src/components/admin/campaigns/grid/CoordinatorSelect.tsx +++ b/src/components/admin/campaigns/grid/CoordinatorSelect.tsx @@ -4,7 +4,7 @@ import { useCoordinatorsList } from 'common/hooks/coordinators' import { useField } from 'formik' import { CoordinatorResponse } from 'gql/coordinators' import { useState } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' export default function CoordinatorSelect({ name = 'coordinatorId' }) { const { t } = useTranslation() diff --git a/src/components/admin/campaigns/grid/OrganizerSelect.tsx b/src/components/admin/campaigns/grid/OrganizerSelect.tsx index e4fbb3c1c..dbcc7a14a 100644 --- a/src/components/admin/campaigns/grid/OrganizerSelect.tsx +++ b/src/components/admin/campaigns/grid/OrganizerSelect.tsx @@ -4,7 +4,7 @@ import { useOrganizersList } from 'common/hooks/organizer' import { useField } from 'formik' import { OrganizerResponse } from 'gql/organizer' import { useState } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' export default function OrganizerSelect({ name = 'organizerId', label = 'campaigns:organizer' }) { const { t } = useTranslation() diff --git a/src/components/admin/companies/CompanySelect.tsx b/src/components/admin/companies/CompanySelect.tsx index d4fe0b06d..8ef8d0cca 100644 --- a/src/components/admin/companies/CompanySelect.tsx +++ b/src/components/admin/companies/CompanySelect.tsx @@ -1,7 +1,7 @@ import { FormControl, FormHelperText, InputLabel, MenuItem, Select } from '@mui/material' import { TranslatableField, translateError } from 'common/form/validation' import { useField } from 'formik' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { useCompaniesList } from 'service/company' export default function CompanySelect({ name = 'companyId', label = '' }) { diff --git a/src/components/admin/documents/grid/DocumentSelect.tsx b/src/components/admin/documents/grid/DocumentSelect.tsx index 5f6f1ea84..cac7f4d7b 100644 --- a/src/components/admin/documents/grid/DocumentSelect.tsx +++ b/src/components/admin/documents/grid/DocumentSelect.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { FormControl, MenuItem } from '@mui/material' import { useField } from 'formik' diff --git a/src/components/admin/donations/grid/GridFilters.tsx b/src/components/admin/donations/grid/GridFilters.tsx index f40361b15..e3d7b9e7f 100644 --- a/src/components/admin/donations/grid/GridFilters.tsx +++ b/src/components/admin/donations/grid/GridFilters.tsx @@ -4,7 +4,7 @@ import { useStores } from '../../../../common/hooks/useStores' import { observer } from 'mobx-react' import { DonationStatus, PaymentProvider } from 'gql/donations.enums' import { DateTimePicker, enUS, LocalizationProvider } from '@mui/x-date-pickers' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { bg } from 'date-fns/locale' import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns' import { fromMoney, toMoney } from 'common/util/money' @@ -48,7 +48,7 @@ export default observer(function GridFilters() { return ( - {formatDateString(row.row.createdAt, i18n.language)} + {formatDateString(row.row.createdAt, i18n?.language)} {row.row.message || row.row.comment} diff --git a/src/components/admin/partners/GiversAndGuarants.tsx b/src/components/admin/partners/GiversAndGuarants.tsx index 613a62b7b..c1e84dd58 100644 --- a/src/components/admin/partners/GiversAndGuarants.tsx +++ b/src/components/admin/partners/GiversAndGuarants.tsx @@ -1,7 +1,7 @@ import { Box, Container, Grid, Typography } from '@mui/material' import Image from 'next/image' import { Fragment } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { givers } from './helpers/giversData' import { data } from './helpers/guarantsData' import { Description, StyledGrid, Subtitle, Title } from './Partners.styled' diff --git a/src/components/admin/partners/PartnersContent.tsx b/src/components/admin/partners/PartnersContent.tsx index a3fb9a16a..b0c44ff00 100644 --- a/src/components/admin/partners/PartnersContent.tsx +++ b/src/components/admin/partners/PartnersContent.tsx @@ -2,7 +2,7 @@ import { Box, Container, Grid } from '@mui/material' import Image from 'next/image' import ExternalLink from 'components/common/ExternalLink' import { Fragment } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import useMobile from '../../../common/hooks/useMobile' import { organizations, partners, techAndMarketingPartners } from './helpers/partnersData' import { SectionTitle, StyledGrid } from './Partners.styled' diff --git a/src/components/admin/recurring-donation/RecurringDonationStatusSelect.tsx b/src/components/admin/recurring-donation/RecurringDonationStatusSelect.tsx index a672cfc0f..4455bc85f 100644 --- a/src/components/admin/recurring-donation/RecurringDonationStatusSelect.tsx +++ b/src/components/admin/recurring-donation/RecurringDonationStatusSelect.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { FormControl, MenuItem } from '@mui/material' import { useField } from 'formik' import { RecurringDonationStatus } from 'gql/recurring-donation-status.d' diff --git a/src/components/admin/vaults/VaultSelect.tsx b/src/components/admin/vaults/VaultSelect.tsx index 7e4e5987c..2190699e7 100644 --- a/src/components/admin/vaults/VaultSelect.tsx +++ b/src/components/admin/vaults/VaultSelect.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { FormControl, MenuItem, TextFieldProps } from '@mui/material' import { useField, useFormikContext } from 'formik' diff --git a/src/components/client/about-project/sections/AboutPlatform/AboutPlatform.tsx b/src/components/client/about-project/sections/AboutPlatform/AboutPlatform.tsx index 160fe145d..2280ee254 100644 --- a/src/components/client/about-project/sections/AboutPlatform/AboutPlatform.tsx +++ b/src/components/client/about-project/sections/AboutPlatform/AboutPlatform.tsx @@ -19,7 +19,7 @@ export default function AboutPlatform() { {/* A11Y TODO: Render the svg without an so screenreaders can read it out */} Podkrepi infographic @@ -28,7 +28,7 @@ export default function AboutPlatform() { {/* A11Y TODO: Render the svg without an so screenreaders can read it out */} Podkrepi infographic diff --git a/src/components/client/auth/profile/DonationTable.tsx b/src/components/client/auth/profile/DonationTable.tsx index 432745e11..000672cc6 100644 --- a/src/components/client/auth/profile/DonationTable.tsx +++ b/src/components/client/auth/profile/DonationTable.tsx @@ -63,7 +63,7 @@ function DonationTable({ donations }: DonationTableProps) { ( - {getRelativeDate(cellValues.row.campaign?.endDate, i18n.language)} + {getRelativeDate(cellValues.row.campaign?.endDate, i18n?.language)} ), }, diff --git a/src/components/client/auth/profile/MyCampaignsTable.tsx b/src/components/client/auth/profile/MyCampaignsTable.tsx index 460d27091..0da8bbd4d 100644 --- a/src/components/client/auth/profile/MyCampaignsTable.tsx +++ b/src/components/client/auth/profile/MyCampaignsTable.tsx @@ -179,7 +179,7 @@ export default function MyCampaingsTable() { renderCell: (cellValues: GridRenderCellParams) => ( ), @@ -192,7 +192,7 @@ export default function MyCampaingsTable() { headerAlign: 'left', renderCell: (cellValues: GridRenderCellParams) => ( - + ), }, @@ -205,7 +205,7 @@ export default function MyCampaingsTable() { renderCell: (cellValues: GridRenderCellParams) => ( ), @@ -219,7 +219,7 @@ export default function MyCampaingsTable() { renderCell: (cellValues: GridRenderCellParams) => ( ), diff --git a/src/components/client/auth/profile/MyDonatedToCampaignsTable.tsx b/src/components/client/auth/profile/MyDonatedToCampaignsTable.tsx index 5ae4d8dd4..40c67550b 100644 --- a/src/components/client/auth/profile/MyDonatedToCampaignsTable.tsx +++ b/src/components/client/auth/profile/MyDonatedToCampaignsTable.tsx @@ -123,7 +123,7 @@ export default function MyDonatedToCampaignTable() { renderCell: (cellValues: GridRenderCellParams) => ( ), @@ -136,7 +136,7 @@ export default function MyDonatedToCampaignTable() { headerAlign: 'left', renderCell: (cellValues: GridRenderCellParams) => ( - + ), }, @@ -149,7 +149,7 @@ export default function MyDonatedToCampaignTable() { renderCell: (cellValues: GridRenderCellParams) => ( ), @@ -163,7 +163,7 @@ export default function MyDonatedToCampaignTable() { renderCell: (cellValues: GridRenderCellParams) => ( ), diff --git a/src/components/client/auth/profile/MyNotificationsCampaignConfirmModal.tsx b/src/components/client/auth/profile/MyNotificationsCampaignConfirmModal.tsx index e12b52203..4e580fe35 100644 --- a/src/components/client/auth/profile/MyNotificationsCampaignConfirmModal.tsx +++ b/src/components/client/auth/profile/MyNotificationsCampaignConfirmModal.tsx @@ -7,7 +7,7 @@ import { AxiosError, AxiosResponse } from 'axios' import { UNsubscribeEmailResponse, UNsubscribeEmailInput } from 'gql/notification' import { ApiError } from 'next/dist/server/api-utils' import { useState } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { useUNsubscribeEmail } from 'service/notification' import { AlertStore } from 'stores/AlertStore' import CloseModalButton from 'components/common/CloseModalButton' diff --git a/src/components/client/auth/profile/MyNotificationsConfirmModal.tsx b/src/components/client/auth/profile/MyNotificationsConfirmModal.tsx index 4623f5ace..8ce724ee5 100644 --- a/src/components/client/auth/profile/MyNotificationsConfirmModal.tsx +++ b/src/components/client/auth/profile/MyNotificationsConfirmModal.tsx @@ -11,7 +11,7 @@ import { import { ApiError } from 'next/dist/server/api-utils' import React from 'react' import { useState } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { useSubscribeEmail, useUNsubscribeEmail } from 'service/notification' import { AlertStore } from 'stores/AlertStore' import { styled } from '@mui/material/styles' diff --git a/src/components/client/auth/profile/MyNotificationsTab.tsx b/src/components/client/auth/profile/MyNotificationsTab.tsx index 56238b3a5..ff289d7bf 100644 --- a/src/components/client/auth/profile/MyNotificationsTab.tsx +++ b/src/components/client/auth/profile/MyNotificationsTab.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { styled } from '@mui/material/styles' import { Box, Button, Card, Typography } from '@mui/material' import { getCurrentPerson } from 'common/util/useCurrentPerson' diff --git a/src/components/client/auth/profile/PersonalInfoTab.tsx b/src/components/client/auth/profile/PersonalInfoTab.tsx index 1e1216c31..bfc495d74 100644 --- a/src/components/client/auth/profile/PersonalInfoTab.tsx +++ b/src/components/client/auth/profile/PersonalInfoTab.tsx @@ -187,7 +187,7 @@ export default function PersonalInfoTab() {

{t('profile:personalInfo.birthday')}

{person?.birthday - ? formatDateString(person?.birthday, i18n.language) + ? formatDateString(person?.birthday, i18n?.language) : t('profile:personalInfo.noBirthday')} diff --git a/src/components/client/blog/DateCreated.tsx b/src/components/client/blog/DateCreated.tsx index 4f5f1f8cb..4a6d9c8e0 100644 --- a/src/components/client/blog/DateCreated.tsx +++ b/src/components/client/blog/DateCreated.tsx @@ -1,6 +1,6 @@ import { Typography } from '@mui/material' import { grey } from '@mui/material/colors' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { formatDateString } from 'common/util/date' @@ -13,7 +13,7 @@ export default function DateCreated({ createdAt, showLabel = false }: Props) { if (!createdAt) return null return ( - {showLabel && t('blog:created-on')} {formatDateString(createdAt, i18n.language)} + {showLabel && t('blog:created-on')} {formatDateString(createdAt, i18n?.language)} ) } diff --git a/src/components/client/blog/ReadingTime.tsx b/src/components/client/blog/ReadingTime.tsx index e273a9751..1613d26de 100644 --- a/src/components/client/blog/ReadingTime.tsx +++ b/src/components/client/blog/ReadingTime.tsx @@ -1,6 +1,6 @@ import { Typography } from '@mui/material' import { grey } from '@mui/material/colors' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' type Props = { readingTime?: number diff --git a/src/components/client/campaign-news/CampaignNewsList.tsx b/src/components/client/campaign-news/CampaignNewsList.tsx index 89eee2989..63b7765f0 100644 --- a/src/components/client/campaign-news/CampaignNewsList.tsx +++ b/src/components/client/campaign-news/CampaignNewsList.tsx @@ -6,7 +6,7 @@ import { styled } from '@mui/material/styles' import { dateToTime, formatDateString } from 'common/util/date' import AvTimerIcon from '@mui/icons-material/AvTimer' import SupervisedUserCircleOutlinedIcon from '@mui/icons-material/SupervisedUserCircleOutlined' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import Image from 'next/image' import { GetArticleDocuments, GetArticleGalleryPhotos } from 'common/util/newsFilesUrls' @@ -108,8 +108,8 @@ export default function CampaignNewsList({ articles }: Props) { - {formatDateString(article.publishedAt, i18n.language)}   - {dateToTime(article.publishedAt, i18n.language)} + {formatDateString(article.publishedAt, i18n?.language)}   + {dateToTime(article.publishedAt, i18n?.language)} diff --git a/src/components/client/campaign-news/SingleArticlePage.tsx b/src/components/client/campaign-news/SingleArticlePage.tsx index 313d34204..6a6e904ac 100644 --- a/src/components/client/campaign-news/SingleArticlePage.tsx +++ b/src/components/client/campaign-news/SingleArticlePage.tsx @@ -4,7 +4,7 @@ import { styled } from '@mui/material/styles' import { formatDateString } from 'common/util/date' import AvTimerIcon from '@mui/icons-material/AvTimer' import SupervisedUserCircleOutlinedIcon from '@mui/icons-material/SupervisedUserCircleOutlined' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import Image from 'next/image' import { GetArticleDocuments, GetArticleGalleryPhotos } from 'common/util/newsFilesUrls' @@ -96,7 +96,7 @@ export default function SingleArticlePage({ slug }: Props) { - {formatDateString(article.publishedAt, i18n.language)} + {formatDateString(article.publishedAt, i18n?.language)} diff --git a/src/components/client/campaign-news/secured/NewsAdminPage.tsx b/src/components/client/campaign-news/secured/NewsAdminPage.tsx index ae1205df3..26cd475c0 100644 --- a/src/components/client/campaign-news/secured/NewsAdminPage.tsx +++ b/src/components/client/campaign-news/secured/NewsAdminPage.tsx @@ -5,7 +5,7 @@ import EditOutlinedIcon from '@mui/icons-material/EditOutlined' import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined' import PageviewOutlinedIcon from '@mui/icons-material/PageviewOutlined' import { DataGrid, GridColDef, GridRenderCellParams } from '@mui/x-data-grid' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { styled } from '@mui/material/styles' import { useState } from 'react' import { formatDateString } from 'common/util/date' @@ -85,7 +85,7 @@ export function NewsAdminPage({ slug, isAdmin }: Props) { flex: 1, minWidth: 140, renderCell: (params: GridRenderCellParams): React.ReactNode => { - return formatDateString(params.row.createdAt, i18n.language) + return formatDateString(params.row.createdAt, i18n?.language) }, }, { @@ -97,7 +97,7 @@ export function NewsAdminPage({ slug, isAdmin }: Props) { minWidth: 200, renderCell: (params: GridRenderCellParams): React.ReactNode => { const date: Date = params.row.publishedAt - return date ? formatDateString(date, i18n.language) : '' + return date ? formatDateString(date, i18n?.language) : '' }, }, { @@ -105,7 +105,7 @@ export function NewsAdminPage({ slug, isAdmin }: Props) { headerName: t('article.lastEdit'), headerClassName: classes.gridColumn, renderCell: (params: GridRenderCellParams): React.ReactNode => { - return params.row.editedAt ? formatDateString(params.row.editedAt, i18n.language) : '' + return params.row.editedAt ? formatDateString(params.row.editedAt, i18n?.language) : '' }, minWidth: 200, flex: 1, diff --git a/src/components/client/campaigns/CampaignCard/CampaignCard.tsx b/src/components/client/campaigns/CampaignCard/CampaignCard.tsx index 2409a19a9..529914cc9 100644 --- a/src/components/client/campaigns/CampaignCard/CampaignCard.tsx +++ b/src/components/client/campaigns/CampaignCard/CampaignCard.tsx @@ -75,14 +75,14 @@ export default function ActiveCampaignCard({ campaign, index }: Props) { - {i18n.language === 'bg' + {i18n?.language === 'bg' ? reachedAmount.split(',')[0] + ' лв.' : reachedAmount.split('.')[0]} - {i18n.language === 'bg' + {i18n?.language === 'bg' ? targetAmount.split(',')[0] + ' лв.' : targetAmount.split('.')[0]} diff --git a/src/components/client/campaigns/CampaignInfo/CampaignInfoStatus.tsx b/src/components/client/campaigns/CampaignInfo/CampaignInfoStatus.tsx index 94f8246e3..9a2a3566d 100644 --- a/src/components/client/campaigns/CampaignInfo/CampaignInfoStatus.tsx +++ b/src/components/client/campaigns/CampaignInfo/CampaignInfoStatus.tsx @@ -17,7 +17,7 @@ type Props = { export default function CampaignInfoStatus({ campaign, showExpensesLink }: Props) { const { t, i18n } = useTranslation() - const locale = i18n.language == 'bg' ? bg : enUS + const locale = i18n?.language == 'bg' ? bg : enUS return ( diff --git a/src/components/client/campaigns/CampaignNewsSection.tsx b/src/components/client/campaigns/CampaignNewsSection.tsx index 74c02fef6..4f1739629 100644 --- a/src/components/client/campaigns/CampaignNewsSection.tsx +++ b/src/components/client/campaigns/CampaignNewsSection.tsx @@ -197,9 +197,9 @@ export default function CampaignNewsSection({ campaign, canCreateArticle }: Prop - {`${formatDateString(article.publishedAt, i18n.language)} ${dateToTime( + {`${formatDateString(article.publishedAt, i18n?.language)} ${dateToTime( article.publishedAt, - i18n.language, + i18n?.language, )}`} @@ -226,9 +226,9 @@ export default function CampaignNewsSection({ campaign, canCreateArticle }: Prop - {`${formatDateString(article.publishedAt, i18n.language)} ${dateToTime( + {`${formatDateString(article.publishedAt, i18n?.language)} ${dateToTime( article.publishedAt, - i18n.language, + i18n?.language, )}`} diff --git a/src/components/client/campaigns/CampaignStateSelect.tsx b/src/components/client/campaigns/CampaignStateSelect.tsx index e30ba61b2..fda1f2ab2 100644 --- a/src/components/client/campaigns/CampaignStateSelect.tsx +++ b/src/components/client/campaigns/CampaignStateSelect.tsx @@ -1,7 +1,7 @@ import { FormControl, FormHelperText, InputLabel, MenuItem, Select } from '@mui/material' import { TranslatableField, translateError } from 'common/form/validation' import { useField } from 'formik' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { CampaignState } from './helpers/campaign.enums' export default function CampaignStateSelect({ name = 'state' }) { diff --git a/src/components/client/campaigns/CampaignTypeSelect.tsx b/src/components/client/campaigns/CampaignTypeSelect.tsx index 93ca73d4a..6d1fa2fb7 100644 --- a/src/components/client/campaigns/CampaignTypeSelect.tsx +++ b/src/components/client/campaigns/CampaignTypeSelect.tsx @@ -2,7 +2,7 @@ import { FormControl, FormHelperText, InputLabel, MenuItem, Select } from '@mui/ import { TranslatableField, translateError } from 'common/form/validation' import { useCampaignTypesList } from 'common/hooks/campaigns' import { useField } from 'formik' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' export default function CampaignTypeSelect({ name = 'campaignTypeId' }) { const { t } = useTranslation() diff --git a/src/components/client/campaigns/DonationWishes.tsx b/src/components/client/campaigns/DonationWishes.tsx index 197634018..3ccc021c9 100644 --- a/src/components/client/campaigns/DonationWishes.tsx +++ b/src/components/client/campaigns/DonationWishes.tsx @@ -37,7 +37,7 @@ type Props = { export default function DonationWishes({ campaignId, pageSize = 5 }: Props) { const { t, i18n } = useTranslation('campaigns') - const locale = i18n.language == 'bg' ? bg : enUS + const locale = i18n?.language == 'bg' ? bg : enUS const titleRef = useRef(null) const [pageIndex, setPageIndex] = useState(0) const [searchValue, setSearchValue] = useState('') diff --git a/src/components/client/campaigns/DonorsAndDonations.tsx b/src/components/client/campaigns/DonorsAndDonations.tsx index 8c4cfd58b..118a12574 100644 --- a/src/components/client/campaigns/DonorsAndDonations.tsx +++ b/src/components/client/campaigns/DonorsAndDonations.tsx @@ -101,7 +101,7 @@ export default function DonorsAndDonations({ | {formatDistanceStrict(parseISO(createdAt), new Date(), { - locale: i18n.language == 'bg' ? bg : enUS, + locale: i18n?.language == 'bg' ? bg : enUS, addSuffix: true, })} diff --git a/src/components/client/campaigns/InlineDonation.tsx b/src/components/client/campaigns/InlineDonation.tsx index bbfbad613..ec9d094bb 100644 --- a/src/components/client/campaigns/InlineDonation.tsx +++ b/src/components/client/campaigns/InlineDonation.tsx @@ -6,7 +6,7 @@ import { useRouter } from 'next/router' import { CampaignResponse } from 'gql/campaigns' import { Button, CircularProgress, Grid, IconButton, Menu, Typography } from '@mui/material' -import { AddLinkOutlined, Favorite, MarkEmailUnread } from '@mui/icons-material' +import { AddLinkOutlined, Favorite } from '@mui/icons-material' import { lighten } from '@mui/material/styles' import { styled } from '@mui/material/styles' import ExpandLessIcon from '@mui/icons-material/ExpandLess' @@ -269,25 +269,25 @@ export default function InlineDonation({ campaign }: Props) { - {i18n.language === 'bg' ? reachedAmount.split(',')[0] : reachedAmount.split('.')[0]} + {i18n?.language === 'bg' ? reachedAmount.split(',')[0] : reachedAmount.split('.')[0]} - {i18n.language === 'bg' + {i18n?.language === 'bg' ? reachedAmount.split(',')[1].substring(0, 2) : reachedAmount.split('.')[1]} - {i18n.language === 'bg' ? {t('donations.lv')} : ''} + {i18n?.language === 'bg' ? {t('donations.lv')} : ''} - {i18n.language === 'bg' ? targetAmount.split(',')[0] : targetAmount.split('.')[0]} + {i18n?.language === 'bg' ? targetAmount.split(',')[0] : targetAmount.split('.')[0]} - {i18n.language === 'bg' + {i18n?.language === 'bg' ? targetAmount.split(',')[1].substring(0, 2) : targetAmount.split('.')[1]} - {i18n.language === 'bg' ? {t('donations.lv')} : ''} + {i18n?.language === 'bg' ? {t('donations.lv')} : ''} diff --git a/src/components/client/faq/FaqSearch.tsx b/src/components/client/faq/FaqSearch.tsx index 732f8f904..dead11564 100644 --- a/src/components/client/faq/FaqSearch.tsx +++ b/src/components/client/faq/FaqSearch.tsx @@ -1,7 +1,7 @@ import React from 'react' import { Box, InputAdornment, TextField } from '@mui/material' import SearchIcon from '@mui/icons-material/Search' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' type Props = { onChange: (newValue: string) => void diff --git a/src/components/client/faq/VerticalTabs.tsx b/src/components/client/faq/VerticalTabs.tsx index 3d0cd82e9..b61bfbde4 100644 --- a/src/components/client/faq/VerticalTabs.tsx +++ b/src/components/client/faq/VerticalTabs.tsx @@ -4,7 +4,7 @@ import { TabList } from '@mui/lab' import Box from '@mui/material/Box' import { useRouter } from 'next/router' import { FaqCategory } from './contents/faq-categories.enum' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' type Props = { faqCategories: FaqCategory[] diff --git a/src/components/client/index/sections/ActiveCampaignsSection/ActiveCampaignCard/ActiveCampaignCard.tsx b/src/components/client/index/sections/ActiveCampaignsSection/ActiveCampaignCard/ActiveCampaignCard.tsx index 26969ddbc..b61e1dd9a 100644 --- a/src/components/client/index/sections/ActiveCampaignsSection/ActiveCampaignCard/ActiveCampaignCard.tsx +++ b/src/components/client/index/sections/ActiveCampaignsSection/ActiveCampaignCard/ActiveCampaignCard.tsx @@ -60,14 +60,14 @@ export default function ActiveCampaignCard({ campaign, index }: Props) { - {i18n.language === 'bg' + {i18n?.language === 'bg' ? reachedAmount.split(',')[0] + ' лв.' : reachedAmount.split('.')[0]} - {i18n.language === 'bg' + {i18n?.language === 'bg' ? targetAmount.split(',')[0] + ' лв.' : targetAmount.split('.')[0]} diff --git a/src/components/client/index/sections/CompletedCampaignsSection/CompletedCampaignsSection.tsx b/src/components/client/index/sections/CompletedCampaignsSection/CompletedCampaignsSection.tsx index cd58e21ec..b25e803c2 100644 --- a/src/components/client/index/sections/CompletedCampaignsSection/CompletedCampaignsSection.tsx +++ b/src/components/client/index/sections/CompletedCampaignsSection/CompletedCampaignsSection.tsx @@ -64,7 +64,7 @@ export default function CompletedCampaignsSection() { - {i18n.language === 'bg' + {i18n?.language === 'bg' ? moneyPublic(campaign.summary.reachedAmount).split(',')[0] + ' лв.' : moneyPublic(campaign.summary.reachedAmount).split('.')[0]} diff --git a/src/components/client/index/sections/HowWeWorkSection/HowWeWorkSection.tsx b/src/components/client/index/sections/HowWeWorkSection/HowWeWorkSection.tsx index 4dc72926f..b8f2a2e49 100644 --- a/src/components/client/index/sections/HowWeWorkSection/HowWeWorkSection.tsx +++ b/src/components/client/index/sections/HowWeWorkSection/HowWeWorkSection.tsx @@ -11,8 +11,8 @@ import { Heading, InfoText } from 'components/client/index/IndexPage.styled' export default function HowWeWorkSection() { const { t, i18n } = useTranslation('index') - const mobileInfographicPath = `/infographic-${i18n.language}-mobile.svg` - const desktopInfographicPath = `/infographic-${i18n.language}.svg` + const mobileInfographicPath = `/infographic-${i18n?.language}-mobile.svg` + const desktopInfographicPath = `/infographic-${i18n?.language}.svg` return ( diff --git a/src/components/client/irregularity/helpers/IrregularityReasonSelect.tsx b/src/components/client/irregularity/helpers/IrregularityReasonSelect.tsx index e10c1868d..2ff8193b5 100644 --- a/src/components/client/irregularity/helpers/IrregularityReasonSelect.tsx +++ b/src/components/client/irregularity/helpers/IrregularityReasonSelect.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { useField, useFormikContext } from 'formik' import { MenuItem, TextField } from '@mui/material' diff --git a/src/components/client/irregularity/helpers/NotifierTypeSelect.tsx b/src/components/client/irregularity/helpers/NotifierTypeSelect.tsx index daa8a59b9..14aafe6f9 100644 --- a/src/components/client/irregularity/helpers/NotifierTypeSelect.tsx +++ b/src/components/client/irregularity/helpers/NotifierTypeSelect.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { MenuItem, TextField } from '@mui/material' import { useField, useFormikContext } from 'formik' diff --git a/src/components/client/irregularity/helpers/StatusSelect.tsx b/src/components/client/irregularity/helpers/StatusSelect.tsx index d2b7c18bf..fcd8f8dbc 100644 --- a/src/components/client/irregularity/helpers/StatusSelect.tsx +++ b/src/components/client/irregularity/helpers/StatusSelect.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { useField, useFormikContext } from 'formik' import { MenuItem, TextField } from '@mui/material' diff --git a/src/components/client/layout/Footer/LogoSocialIcons.tsx b/src/components/client/layout/Footer/LogoSocialIcons.tsx index 376610c78..5460efe7b 100644 --- a/src/components/client/layout/Footer/LogoSocialIcons.tsx +++ b/src/components/client/layout/Footer/LogoSocialIcons.tsx @@ -1,6 +1,6 @@ import Link from 'next/link' import { useRouter } from 'next/router' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Grid } from '@mui/material' import { routes } from 'common/routes' diff --git a/src/components/client/layout/Footer/SubscribeBtn.tsx b/src/components/client/layout/Footer/SubscribeBtn.tsx index 65bee5a63..7529033fb 100644 --- a/src/components/client/layout/Footer/SubscribeBtn.tsx +++ b/src/components/client/layout/Footer/SubscribeBtn.tsx @@ -1,5 +1,5 @@ import { Typography } from '@mui/material' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { SubscribeLinkWrapper } from './Footer.styled' import { useState } from 'react' import RenderSubscribeModal from 'components/client/notifications/GeneralSubscribeModal' diff --git a/src/components/client/layout/Layout.tsx b/src/components/client/layout/Layout.tsx index fbb64ebf8..564145045 100644 --- a/src/components/client/layout/Layout.tsx +++ b/src/components/client/layout/Layout.tsx @@ -89,7 +89,7 @@ export default function Layout({ )} - + {/* TODO: think of how to make campaign level localization */} @@ -106,8 +106,11 @@ export default function Layout({