diff --git a/README.md b/README.md index 7ffa99239..614bd7ec0 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-71-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/campaigns.json b/public/locales/bg/campaigns.json index 0b7aa634b..aafbf315b 100644 --- a/public/locales/bg/campaigns.json +++ b/public/locales/bg/campaigns.json @@ -97,8 +97,8 @@ "status": "Статус:", "messages": "Кампанията подкрепиха:", "sort": { - "title" : "Сортирай по:", - "date" : "Дата", + "title": "Сортирай по:", + "date": "Дата", "amount": "Дарение", "search": "Търси...", "noResults": "Не са открити резултати" diff --git a/public/locales/en/campaigns.json b/public/locales/en/campaigns.json index a489771b8..1805bec72 100644 --- a/public/locales/en/campaigns.json +++ b/public/locales/en/campaigns.json @@ -90,8 +90,8 @@ "others": "others", "messages": "Messages:", "sort": { - "title" : "Sort by:", - "date" : "Date", + "title": "Sort by:", + "date": "Date", "amount": "Amount", "search": "Search...", "noResults": "No messages found" diff --git a/src/components/admin/InfoRequestBottomAppBar.tsx b/src/components/admin/InfoRequestBottomAppBar.tsx index 1559c0198..9bcb951a6 100644 --- a/src/components/admin/InfoRequestBottomAppBar.tsx +++ b/src/components/admin/InfoRequestBottomAppBar.tsx @@ -1,11 +1,5 @@ import { Box, Toolbar, Tooltip, Typography } from '@mui/material' -import { - Add as AddIcon, - Print as PrintIcon, - Save as SaveIcon, - Share as ShareIcon, - EventNote as EventNoteIcon, -} from '@mui/icons-material' +import { Add as AddIcon } from '@mui/icons-material' const addIconStyles = { background: '#4ac3ff', @@ -14,14 +8,6 @@ const addIconStyles = { padding: 1.2, boxShadow: 3, } -const iconStyles = { - background: 'white', - borderRadius: '50%', - cursor: 'pointer', - padding: 0.5, - boxShadow: 3, - mr: 1, -} export default function InfoRequestBottomAppBar() { return ( diff --git a/src/components/admin/bankaccounts/grid/GridAppbar.tsx b/src/components/admin/bankaccounts/grid/GridAppbar.tsx index 5976640f6..632cb265c 100644 --- a/src/components/admin/bankaccounts/grid/GridAppbar.tsx +++ b/src/components/admin/bankaccounts/grid/GridAppbar.tsx @@ -1,12 +1,6 @@ import { useRouter } from 'next/router' import { Box, Toolbar, Tooltip, Typography } from '@mui/material' -import { - Add as AddIcon, - Print as PrintIcon, - Save as SaveIcon, - Share as ShareIcon, - EventNote as EventNoteIcon, -} from '@mui/icons-material' +import { Add as AddIcon } from '@mui/icons-material' import { routes } from 'common/routes' @@ -17,14 +11,6 @@ const addIconStyles = { padding: 1.2, boxShadow: 3, } -const iconStyles = { - background: 'white', - borderRadius: '50%', - cursor: 'pointer', - padding: 0.5, - boxShadow: 3, - mr: 1, -} export default function GridAppbar() { const router = useRouter() diff --git a/src/components/admin/donations/CreatePage.tsx b/src/components/admin/donations/CreatePage.tsx deleted file mode 100644 index a84498877..000000000 --- a/src/components/admin/donations/CreatePage.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useTranslation } from 'next-i18next' -import { Container } from '@mui/material' - -import AdminContainer from 'components/common/navigation/AdminContainer' -import AdminLayout from 'components/common/navigation/AdminLayout' - -import Form from './Form' - -export default function CreatePage() { - const { t } = useTranslation() - - return ( - - - -
- - - - ) -} diff --git a/src/components/admin/donations/EditPage.tsx b/src/components/admin/donations/EditPage.tsx deleted file mode 100644 index af9ffa68e..000000000 --- a/src/components/admin/donations/EditPage.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useTranslation } from 'next-i18next' -import { Container } from '@mui/material' - -import AdminContainer from 'components/common/navigation/AdminContainer' -import AdminLayout from 'components/common/navigation/AdminLayout' - -import Form from './Form' - -export default function EditPage() { - const { t } = useTranslation() - - return ( - - - - - - - - ) -} diff --git a/src/components/admin/donations/Form.tsx b/src/components/admin/donations/Form.tsx deleted file mode 100644 index 4e0c9da62..000000000 --- a/src/components/admin/donations/Form.tsx +++ /dev/null @@ -1,308 +0,0 @@ -import React, { useState } from 'react' -import { useMutation, UseQueryResult } from '@tanstack/react-query' -import { useRouter } from 'next/router' -import { useTranslation } from 'next-i18next' -import Link from 'next/link' -import { AxiosError, AxiosResponse } from 'axios' -import * as yup from 'yup' -import { - Box, - Button, - FormControl, - Grid, - InputLabel, - MenuItem, - Select, - Typography, -} from '@mui/material' - -import { routes } from 'common/routes' -import { ApiErrors, handleUniqueViolation } from 'service/apiErrors' -import { AlertStore } from 'stores/AlertStore' -import GenericForm from 'components/common/form/GenericForm' -import FormTextField from 'components/common/form/FormTextField' -import SubmitButton from 'components/common/form/SubmitButton' -import { DonationInput, DonationResponse } from 'gql/donations' -import { useDonation } from 'common/hooks/donation' -import { useCreateDonation, useEditDonation } from 'service/donation' -import { useVaultsList } from 'common/hooks/vaults' -import { DateTimePicker, LocalizationProvider } from '@mui/x-date-pickers' -import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns' -import { bg, enUS } from 'date-fns/locale' - -const validDonationTypes = ['donation'] -const validDonationStatuses = [ - 'initial', - 'invalid', - 'incomplete', - 'declined', - 'waiting', - 'cancelled', - 'succeeded', - 'deleted', - 'refund', - 'paymentRequested', -] -const validProviders = ['none', 'stripe', 'paypal', 'epay', 'bank', 'cash'] -const validCurrencies = ['BGN', 'EUR'] - -const validationSchema = yup.object().defined().shape({ - amount: yup.number().positive().required(), -}) - -export default function EditForm() { - const { t, i18n } = useTranslation() - const [type, setType] = useState('donation') - const [status, setStatus] = useState('initial') - const [provider, setProvider] = useState('none') - const [currency, setCurrency] = useState('') - const [vault, setVault] = useState('') - const [date, setToDate] = React.useState(new Date()) - const router = useRouter() - - let id = router.query.id - - const vaults = useVaultsList().data - - let initialValues: DonationInput = { - type: 'donation', - status: 'initial', - provider: 'none', - currency: '', - amount: 0, - createdAt: new Date(), - targetVaultId: '', - extCustomerId: '', - extPaymentIntentId: '', - extPaymentMethodId: '', - } - - if (id) { - id = String(id) - const { data }: UseQueryResult = useDonation(id) - - if (data) { - initialValues = { - type: data?.type.toString(), - status: data?.status.toString(), - provider: data?.provider.toString(), - createdAt: data?.createdAt, - currency: data?.currency.toString(), - amount: data?.amount, - targetVaultId: data?.targetVaultId, - extCustomerId: data?.extCustomerId, - extPaymentIntentId: data?.extPaymentIntentId, - extPaymentMethodId: data?.extPaymentMethodId, - } - } - } - - const mutationFn = id ? useEditDonation(id) : useCreateDonation() - - const handleError = (e: AxiosError) => { - const error = e.response - - if (error?.status === 409) { - const message = error.data.message.map((el) => handleUniqueViolation(el.constraints, t)) - return AlertStore.show(message.join('/n'), 'error') - } - - AlertStore.show(t('donations:alerts:error'), 'error') - } - - const mutation = useMutation< - AxiosResponse, - AxiosError, - DonationInput - >({ - mutationFn, - onError: (error) => handleError(error), - onSuccess: () => { - AlertStore.show(id ? t('donations:alerts:edit') : t('donations:alerts:create'), 'success') - router.push(routes.admin.donations.index) - }, - }) - - async function onSubmit(data: DonationInput) { - type ? (data.type = type) : '' - status ? (data.status = status) : '' - provider ? (data.provider = provider) : '' - currency ? (data.currency = currency) : '' - vault ? (data.targetVaultId = vault) : '' - - mutation.mutate(data) - } - - return ( - - - - {id ? t('donations:edit-form-heading') : t('donations:form-heading')} - - - - - {t('donations:type')} - - - - - - {t('donations:status')} - - - - - - {t('donations:provider')} - - - - - - - - - - - {t('donations:vault')} - - - - - - - - - - - - - - - - - - {t('donations:currency')} - - - - - - - - - - - - - - - ) -} diff --git a/src/components/admin/donations/grid/GridAppbar.tsx b/src/components/admin/donations/grid/GridAppbar.tsx index da6f31fa4..f153ba4bd 100644 --- a/src/components/admin/donations/grid/GridAppbar.tsx +++ b/src/components/admin/donations/grid/GridAppbar.tsx @@ -1,7 +1,7 @@ import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' import { Box, TextField, Toolbar, Tooltip, Typography } from '@mui/material' -import { Add as AddIcon, Receipt, GetApp as DownloadFileIcon } from '@mui/icons-material' +import { Receipt, GetApp as DownloadFileIcon } from '@mui/icons-material' import { routes } from 'common/routes' import { useMutation } from '@tanstack/react-query' @@ -83,13 +83,6 @@ export default function GridAppbar() { onClick={() => router.push(routes.admin.donations.addBankTransactionsFile)} /> - - router.push(routes.admin.donations.create)} - /> - endpoints.donation.getDonation(ctx.query.id as string).url, -) - -export default EditPage diff --git a/src/pages/admin/donations/create.tsx b/src/pages/admin/donations/create.tsx deleted file mode 100644 index c7a5c10d4..000000000 --- a/src/pages/admin/donations/create.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import CreatePage from 'components/admin/donations/CreatePage' -import { securedPropsWithTranslation } from 'middleware/auth/securedProps' - -export const getServerSideProps = securedPropsWithTranslation([ - 'common', - 'auth', - 'donations', - 'validation', -]) -export default CreatePage diff --git a/src/service/apiEndpoints.ts b/src/service/apiEndpoints.ts index 2b2580e5c..b95bab6c7 100644 --- a/src/service/apiEndpoints.ts +++ b/src/service/apiEndpoints.ts @@ -79,7 +79,6 @@ export const endpoints = { recurringPrices: { url: '/donation/prices/recurring', method: 'GET' }, createCheckoutSession: { url: '/donation/create-checkout-session', method: 'POST' }, createPaymentIntent: { url: '/donation/create-payment-intent', method: 'POST' }, - createDonation: { url: '/donation/create-payment', method: 'POST' }, createBankDonation: { url: '/donation/create-bank-payment', method: 'POST' }, getDonation: (id: string) => { url: `/donation/${id}`, method: 'GET' }, donationsList: ( diff --git a/src/service/donation.ts b/src/service/donation.ts index e0aa887cd..71ad192ae 100644 --- a/src/service/donation.ts +++ b/src/service/donation.ts @@ -7,7 +7,6 @@ import { CheckoutSessionInput, CheckoutSessionResponse, DonationBankInput, - DonationInput, DonationResponse, UserDonationInput, } from 'gql/donations' @@ -36,17 +35,6 @@ export function useCreatePaymentIntent(params: Stripe.PaymentIntentCreateParams) }) } -export function useCreateDonation() { - const { data: session } = useSession() - return async (data: DonationInput) => { - return await apiClient.post>( - endpoints.donation.createDonation.url, - data, - authConfig(session?.accessToken), - ) - } -} - export function useCreateBankDonation() { // const { data: session } = useSession() return async (data: DonationBankInput) => {