-
Notifications
You must be signed in to change notification settings - Fork 0
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 #25 from wafflestudio/develop
Add Email Verification to main
- Loading branch information
Showing
24 changed files
with
526 additions
and
109 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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,69 @@ | ||
import styled, { keyframes } from "styled-components"; | ||
|
||
import alertTriangleRed from "../assets/alert/alertTriangleRed.svg"; | ||
import circleCheckGreen from "../assets/alert/circleCheckGreen.svg"; | ||
|
||
interface SnackBarProps extends React.HTMLAttributes<HTMLDivElement> { | ||
isSuccess: boolean; | ||
message: string; | ||
} | ||
|
||
function SnackBar({ isSuccess, message, ...props }: SnackBarProps) { | ||
return ( | ||
<Container isSuccess={isSuccess} {...props}> | ||
<img src={isSuccess ? circleCheckGreen : alertTriangleRed} alt="icon" /> | ||
<h2>{message}</h2> | ||
</Container> | ||
); | ||
} | ||
|
||
const fadeIn = keyframes` | ||
from { | ||
opacity: 0; | ||
} | ||
to { | ||
opacity: 1; | ||
} | ||
`; | ||
|
||
const fadeOut = keyframes` | ||
from { | ||
opacity: 1; | ||
} | ||
to { | ||
opacity: 0; | ||
} | ||
`; | ||
|
||
const Container = styled.div<{ isSuccess: boolean }>` | ||
display: flex; | ||
flex-direction: row; | ||
width: 85%; | ||
height: 5.6rem; | ||
padding: 1.6rem 2.4rem; | ||
gap: 1rem; | ||
border-radius: 0.8rem; | ||
position: absolute; | ||
bottom: 3rem; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
background-color: ${({ theme, isSuccess }) => | ||
isSuccess ? theme.colors.green[50] : theme.colors.red[50]}; | ||
animation: | ||
${fadeIn} 0.2s ease-in, | ||
${fadeOut} 0.2s ease-out 2s; | ||
& h2 { | ||
${({ theme }) => theme.typography.b2}; | ||
color: ${({ theme, isSuccess }) => | ||
isSuccess ? "#559764" : theme.colors.red[500]}; | ||
} | ||
`; | ||
|
||
export default SnackBar; |
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 |
---|---|---|
|
@@ -121,6 +121,8 @@ const ContentLink = styled(Link)` | |
p.description { | ||
flex: 1; | ||
white-space: pre-wrap; | ||
} | ||
`; | ||
|
||
|
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,27 @@ | ||
import { useState, useRef } from "react"; | ||
|
||
function useSnackbar() { | ||
const [showSnackbar, setShowSnackbar] = useState(false); | ||
const snackbarTimeoutRef = useRef<NodeJS.Timeout | null>(null); | ||
|
||
const show = () => { | ||
setShowSnackbar(true); | ||
if (snackbarTimeoutRef.current) { | ||
clearTimeout(snackbarTimeoutRef.current); | ||
} | ||
snackbarTimeoutRef.current = setTimeout(() => { | ||
setShowSnackbar(false); | ||
}, 2200); | ||
}; | ||
|
||
const hide = () => { | ||
setShowSnackbar(false); | ||
if (snackbarTimeoutRef.current) { | ||
clearTimeout(snackbarTimeoutRef.current); | ||
} | ||
}; | ||
|
||
return { showSnackbar, show, hide }; | ||
} | ||
|
||
export default useSnackbar; |
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,39 @@ | ||
import { useState, useRef, useCallback } from "react"; | ||
|
||
// Utility function to wrap synchronous functions in a Promise | ||
function toAsync(fn: () => void | Promise<void>): () => Promise<void> { | ||
return async () => { | ||
if (fn.length === 0) { | ||
return Promise.resolve(fn()); | ||
} else { | ||
return fn(); | ||
} | ||
}; | ||
} | ||
|
||
function useSubmitHandler() { | ||
const [isSubmitting, setIsSubmitting] = useState(false); | ||
const isSubmittingRef = useRef(isSubmitting); | ||
|
||
const handleSubmit = useCallback( | ||
async (submitFunction: () => void | Promise<void>) => { | ||
if (isSubmittingRef.current) return; | ||
|
||
setIsSubmitting(true); | ||
isSubmittingRef.current = true; | ||
|
||
try { | ||
const asyncSubmitFunction = toAsync(submitFunction); | ||
await asyncSubmitFunction(); | ||
} finally { | ||
setIsSubmitting(false); | ||
isSubmittingRef.current = false; | ||
} | ||
}, | ||
[] | ||
); | ||
|
||
return { isSubmitting, handleSubmit }; | ||
} | ||
|
||
export default useSubmitHandler; |
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
Oops, something went wrong.