Skip to content

Commit

Permalink
feat: loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
flornkm committed May 27, 2024
1 parent 477d39a commit aee2a27
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion interface/sections/Letters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ function SendLetter(props: {
const handleInput = useRef<HTMLInputElement>(null)
const [letterWritten, setLetterWritten] = useState(false)
const [signature, setSignature] = useState("")
const [loading, setLoading] = useState(false)

useEffect(() => {
const signField = new SignaturePad(canvasRef.current!)
Expand Down Expand Up @@ -396,8 +397,9 @@ function SendLetter(props: {
type="primary"
rounded
chevron
disabled={signature.length === 0}
disabled={signature.length === 0 || loading}
function={async () => {
setLoading(true)
const sendLetter = await fetch("/api/letters", {
method: "POST",
headers: {
Expand All @@ -414,6 +416,7 @@ function SendLetter(props: {
props.setShowLetter(true)
fetchLetters().then((data) => {
props.setLetters(data)
setLoading(false)
})
} else console.error("Could not send letter")
}}
Expand Down

0 comments on commit aee2a27

Please sign in to comment.