Skip to content

Commit

Permalink
unused code deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
RalitsaIlieva committed Jan 3, 2024
1 parent e39e05f commit be2105a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const Subtitle = styled(Typography)(() => ({
display: 'inline-block',
fontSize: theme.typography.pxToRem(16),
lineHeight: theme.spacing(3),
marginTop: theme.spacing(2),
}))

export const HelpThoseInNeedButton = styled(LinkButton)(() => ({
Expand Down Expand Up @@ -79,13 +78,6 @@ export const SubscribeHeading = styled(Typography)(() => ({
fontWeight: 500,
fontSize: theme.typography.pxToRem(16.5),
textAlign: 'center',

'&:hover': {
textDecoration: 'underline',
transform: 'scale(1.01)',
cursor: 'pointer',
transition: 'all 0.3s ease',
},
}))

export const SubscribeButton = styled(Button)(() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,9 @@ export default function PlatformStatisticsSection() {
{t('index:platform-statistics.donate-to-those-in-need')}
</HelpThoseInNeedButton>
{subscribeIsOpen && <RenderSubscribeModal setOpen={setSubscribeOpen} />}
<Grid item xs={12} display="flex" sx={{ mt: 1.5, mb: 0.5 }}>
<EmailIcon
color="primary"
fontSize="small"
sx={{ mr: 0.5 }}
onClick={() => setSubscribeOpen(true)}
cursor="pointer"
/>
<SubscribeHeading onClick={() => setSubscribeOpen(true)}>
{t('campaigns:cta.subscribeGeneral')}
</SubscribeHeading>
<Grid item xs={12} display="flex" sx={{ mt: 3.5, mb: 0.5 }}>
<EmailIcon color="primary" fontSize="small" sx={{ mr: 0.5 }} cursor="pointer" />
<SubscribeHeading>{t('campaigns:cta.subscribeGeneral')}</SubscribeHeading>
</Grid>
<Subtitle>{t('campaigns:cta.subscribeGeneralSubtext')}</Subtitle>
<SubscribeButton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import React, { useState } from 'react'
import * as yup from 'yup'
import { useTranslation } from 'next-i18next'
import { useMutation } from '@tanstack/react-query'
import { AxiosError, AxiosResponse } from 'axios'
import { ApiError } from 'next/dist/server/api-utils'
import { AlertStore } from 'stores/AlertStore'
import { email } from 'common/form/validation'
import { Heading } from '../../IndexPage.styled'
import { InfoText } from './SubscriptionSection.styled'
import { Grid } from '@mui/material'
import ArrowForwardSharp from '@mui/icons-material/ArrowForwardSharp'
import { useSendConfirmationEmail } from 'service/notification'
import { SendConfirmationEmailResponse, SendConfirmationEmailInput } from 'gql/notification'
import EmailIcon from '@mui/icons-material/Email'
import RenderSubscribeModal from 'components/client/notifications/GeneralSubscribeModal'
import {
Expand All @@ -25,49 +17,10 @@ export type SubscribeToNotificationsInput = {
email: string
}

const validationSchema: yup.SchemaOf<SubscribeToNotificationsInput> = yup.object().defined().shape({
email: email.required(),
})

const SubscriptionSection = () => {
const { t } = useTranslation()
const [loading, setLoading] = useState(false)
const [open, setOpen] = useState(false)
const [email, setEmail] = useState('')
const [subscribeIsOpen, setSubscribeOpen] = useState(false)

async function onSubmit(values: { email: string }) {
setLoading(true)
setEmail(values.email)
try {
await mutation.mutateAsync(values)
setOpen(true)
} finally {
setLoading(false)
}
}

const onClose = () => {
setOpen(false)
}

const handleError = (e: AxiosError<ApiError>) => {
const error = e.response?.data?.message
AlertStore.show(error ? error : t('common:alerts.error'), 'error')
}

const mutation = useMutation<
AxiosResponse<SendConfirmationEmailResponse>,
AxiosError<ApiError>,
SendConfirmationEmailInput
>({
mutationFn: useSendConfirmationEmail(),
onError: (error) => handleError(error),
onSuccess: () => {
AlertStore.show(t('common:alerts.message-sent'), 'success')
},
})

return (
<SectionGridWrapper
sx={(theme) => ({
Expand All @@ -80,7 +33,7 @@ const SubscriptionSection = () => {
textAlign: 'center',
})}>
<Heading variant="h4">{t('index:subscription-section.heading')}</Heading>
<InfoText maxWidth="lg">{t('index:subscription-section.content')}</InfoText>
<InfoText>{t('index:subscription-section.content')}</InfoText>
{subscribeIsOpen && <RenderSubscribeModal setOpen={setSubscribeOpen} />}
<Grid item xs={12} display="flex" mb={0.5} justifyContent="center">
<EmailIcon
Expand Down

0 comments on commit be2105a

Please sign in to comment.