-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from aniketbiswas21/unsubscribe
feat: added unsubscribe page and docker-dev setup
- Loading branch information
Showing
11 changed files
with
266 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import styled from "styled-components"; | ||
import { Input, FormItem } from "formik-antd"; | ||
import { sm, xs } from "theme/breakpoints"; | ||
|
||
export const UnsubscribeWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
h1 { | ||
text-align: center; | ||
margin: auto; | ||
color: ${({ theme }) => theme.secondaryColor}; | ||
font-weight: 800; | ||
font-size: 2rem; | ||
${sm} { | ||
font-size: 1.8rem; | ||
line-height: 1.6rem; | ||
} | ||
${xs} { | ||
font-size: 1.4rem; | ||
line-height: 1.6rem; | ||
} | ||
} | ||
img { | ||
margin-top: 1rem; | ||
object-fit: contain; | ||
height: 500px; | ||
border-radius: 20px; | ||
${xs}, | ||
${sm} { | ||
height: 300px; | ||
width: 100%; | ||
margin: 1rem auto; | ||
} | ||
} | ||
.form { | ||
display: flex; | ||
margin: 3rem auto; | ||
width: 100%; | ||
justify-content: center; | ||
${xs} { | ||
flex-direction: column; | ||
} | ||
} | ||
.submit { | ||
margin-left: 0.5rem; | ||
${xs} { | ||
margin-left: 0; | ||
} | ||
} | ||
`; | ||
|
||
export const StyledInput = styled(Input)` | ||
width: 100%; | ||
margin: auto; | ||
`; | ||
|
||
export const StyledFormItem = styled(FormItem)` | ||
display: flex; | ||
justify-content: center; | ||
width: 60%; | ||
@media only screen and (max-width: 1600px) { | ||
width: 30%; | ||
} | ||
${sm} { | ||
width: 100%; | ||
} | ||
${xs} { | ||
width: 100%; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React from "react"; | ||
import Layout from "components/Layout/Layout"; | ||
import { Button, Col, message, notification, Row } from "antd"; | ||
import { Formik, FormikProps } from "formik"; | ||
import { Form } from "formik-antd"; | ||
import { useMutation } from "react-query"; | ||
import { unsubsribeByEmail } from "services/api"; | ||
import { UnsubscribeSchema } from "utils/UnsubscribeSchema"; | ||
|
||
import { | ||
UnsubscribeWrapper, | ||
StyledInput, | ||
StyledFormItem, | ||
} from "./Unsubscribe.styles"; | ||
import happyVaccine from "../../assets/happyVaccine.jpg"; | ||
|
||
interface FormValues { | ||
email: string; | ||
} | ||
|
||
interface OtherProps { | ||
handleSubmit: (e?: React.FormEvent<HTMLFormElement> | undefined) => void; | ||
isValid: boolean; | ||
} | ||
|
||
const initialValues: FormValues = { | ||
email: "", | ||
}; | ||
|
||
const Unsubscribe: React.FC = () => { | ||
const { isLoading, mutate } = useMutation( | ||
(email: string) => unsubsribeByEmail(email), | ||
{ | ||
onSuccess: (data: string) => { | ||
notification.success({ | ||
message: data, | ||
placement: "bottomRight", | ||
}); | ||
}, | ||
onError: (err) => { | ||
console.log(err); | ||
notification.error({ | ||
message: "Something went wrong", | ||
description: "Please try again later", | ||
placement: "bottomRight", | ||
}); | ||
}, | ||
} | ||
); | ||
const onSubmit = (formik: OtherProps & FormikProps<FormValues>): void => { | ||
const { handleSubmit, isValid } = formik; | ||
if (!isValid) { | ||
message.error("Please fill all the details correctly", 2); | ||
} else { | ||
handleSubmit(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Layout> | ||
<Row justify="center"> | ||
<Col xs={24} sm={24} md={24} lg={24} xl={24} xxl={14}> | ||
<UnsubscribeWrapper> | ||
<h1> | ||
Thank you for using Covaccinate! We hope, we could be of help! | ||
</h1> | ||
<img src={happyVaccine} alt="Happy Vaccine" /> | ||
<Formik | ||
initialValues={initialValues} | ||
validationSchema={UnsubscribeSchema} | ||
onSubmit={(values) => { | ||
mutate(values.email); | ||
}} | ||
> | ||
{(props) => { | ||
const { email } = props.values; | ||
|
||
return ( | ||
<Form className="form"> | ||
<StyledFormItem name="email"> | ||
<StyledInput | ||
placeholder="Enter your registered email" | ||
value={email} | ||
size="large" | ||
name="email" | ||
onChange={props.handleChange} | ||
/> | ||
</StyledFormItem> | ||
<Button | ||
type="primary" | ||
size="large" | ||
className="submit" | ||
onClick={() => { | ||
onSubmit(props); | ||
}} | ||
loading={isLoading} | ||
> | ||
Unsubscribe | ||
</Button> | ||
</Form> | ||
); | ||
}} | ||
</Formik> | ||
</UnsubscribeWrapper> | ||
</Col> | ||
</Row> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Unsubscribe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as Yup from "yup"; | ||
|
||
export const UnsubscribeSchema = Yup.object().shape({ | ||
email: Yup.string().email("Invalid email").required("Required"), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM nginx:1.19.0-alpine | ||
|
||
RUN rm /etc/nginx/conf.d/default.conf | ||
COPY nginx.dev.conf /etc/nginx/conf.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
upstream client { | ||
server client:3000; | ||
} | ||
|
||
upstream jabme { | ||
server web:8000; | ||
} | ||
|
||
|
||
server { | ||
listen 80; | ||
|
||
location /api { | ||
proxy_pass http://jabme; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $host; | ||
proxy_redirect off; | ||
} | ||
|
||
location /admin { | ||
proxy_pass http://jabme; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $host; | ||
proxy_redirect off; | ||
} | ||
|
||
location /staticfiles/ { | ||
alias /home/app/web/staticfiles/; | ||
} | ||
|
||
location /sockjs-node { | ||
proxy_pass http://client; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
} | ||
|
||
location / { | ||
proxy_pass http://client; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $host; | ||
proxy_redirect off; | ||
} | ||
|
||
} |