Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE][86drmx95g] Send email when someone subscribes to EO #113

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion apps/eo_web/src/api/email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { apiElixir } from "~/api/axios";
import { apiElixir, apiLaravel } from "~/api/axios";

export interface ResendEmailVerificationResponse {
success: boolean;
Expand All @@ -10,3 +10,14 @@ export const resendEmailVerification = async (email: string) => {
{ email },
);
};

export interface SubscribeToEoEmailPostResponse {
success: boolean;
}

export const subscribeToEoEmailPost = async (email: string) => {
return await apiLaravel.post<SubscribeToEoEmailPostResponse>(
"/api/slack-notification/eo-subscription",
{ email },
);
};
26 changes: 22 additions & 4 deletions apps/eo_web/src/components/EOInYourInbox.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { Button, Typography } from '@eo/ui'
import React, { useState } from 'react'
import { useMutation } from '@tanstack/react-query'
import { subscribeToEoEmailPost } from '~/api/email'
import { toast } from 'react-toastify'

export const EOInYourInbox = () => {
const [submitted, setSubmitted] = useState(false)
const [email, setEmail] = useState('')

const { mutate, isLoading } = useMutation({
mutationFn: subscribeToEoEmailPost,
onSuccess: () => setSubmitted(true),
onError: () => toast.error("Something went wrong, try again.")
Mat0ias marked this conversation as resolved.
Show resolved Hide resolved
});

return (
<section className="w-full bg-white px-6 py-12 md:px-[50px] md:py-[100px]">
<div className="flex flex-col items-center">
Expand All @@ -17,15 +28,22 @@ export const EOInYourInbox = () => {
special offers are all coming soon.
</Typography>
{!submitted ?
(<div className="mt-[30px] flex w-full flex-col justify-items-end gap-4 md:w-auto md:flex-row">
(<form onSubmit={
(e) => {
e.preventDefault()
mutate(email)
}} className="mt-[30px] flex w-full flex-col justify-items-end gap-4 md:w-auto md:flex-row">
<input
className="h-[49px] w-full rounded-[40px] border border-solid border-black bg-white py-3 pl-4 pr-2 text-black placeholder:text-gray-300 md:w-[327px]"
placeholder="Enter your email..."
type='email'
value={email}
onChange={(e) => { setEmail(e.target.value) }}
/>
<Button variant="black" font="semiBold" onClick={() => setSubmitted(true)}>
<Button type='submit' variant="black" font="semiBold" disabled={isLoading || !email}>
Subscribe
</Button>
</div>
</form>
) : (
<div className="mt-[30px] px-6 py-12 lg:px-32 lg:py-18 rounded-lg border-2 border-black">
<Typography font="semiBold" className="text-center text-lg ">
Expand All @@ -35,6 +53,6 @@ export const EOInYourInbox = () => {
</div>
)}
</div>
</section>
</section >
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const EmailVerificationUncompletedButLogged = () => {

return (
<LayoutDefault>
<div className="flex h-full h-full flex-col items-center justify-center px-2">
<div className="flex h-full flex-col items-center justify-center px-2">
<Typography variant="large" font="bold">
It looks like you haven’t verified your email.{" "}
<br className="hidden md:block" /> Try checking your junk or spam
Expand Down
9 changes: 6 additions & 3 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"enableFiletypes": ["astro"],
"enableFiletypes": [
"astro"
],
"ignorePaths": [
"*node_modules",
"*tsconfig.tsbuildinfo",
Expand Down Expand Up @@ -30,6 +32,7 @@
"ianvs",
"iconify",
"jotform",
"LARAVEL",
"manypkg",
"medtech",
"middlewares",
Expand All @@ -53,8 +56,8 @@
"Viewports",
"WORKDIR",
"xlink",
"zustand",
"Zuko",
"ZUKO",
"Zuko"
"zustand"
]
}
2 changes: 1 addition & 1 deletion packages/ui/src/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Button = forwardRef(
ref={ref}
type={type}
className={tw(
"flex h-12 flex-row items-center justify-between gap-2 border border-transparent text-center focus:outline-none",
"flex h-12 flex-row items-center justify-between gap-2 border border-transparent text-center focus:outline-none disabled:opacity-40",
"rounded-[37.3px] focus:ring-2 focus:ring-offset-0",
!left && !right && "justify-center",
variant === "primary" &&
Expand Down
Loading