-
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.
- Loading branch information
Showing
3 changed files
with
83 additions
and
80 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
/** | ||
* External modules | ||
*/ | ||
import React, { useCallback, useState } from "react"; | ||
import styled from "styled-components"; | ||
import { Button, Input, Popover, Typography } from "antd"; | ||
import axios from "axios"; | ||
|
||
const EMAIL_API = "https://api.jaewook.me/email/addr-extension-feedback"; | ||
|
||
const PopoverTitleWrapper = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
`; | ||
|
||
const PopoverTitle = (props: { children: React.ReactNode }) => { | ||
return <PopoverTitleWrapper>{props.children}</PopoverTitleWrapper>; | ||
}; | ||
|
||
const FeedbackSenderWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
> button.ant-btn { | ||
margin-top: 8px; | ||
width: 100%; | ||
} | ||
`; | ||
|
||
const PopoverContentStyle = { | ||
width: "270px", | ||
}; | ||
|
||
const FeedbackForm = () => { | ||
const [message, setMessage] = useState(""); | ||
const [sending, setSending] = useState(false); | ||
const [sent, setSent] = useState(false); | ||
|
||
const handleSendClick = useCallback(async () => { | ||
if (sent || !message) { | ||
return; | ||
} | ||
setSending(true); | ||
try { | ||
await axios.post(EMAIL_API, { feedbackContent: message }); | ||
setSent(true); | ||
} catch (err) { | ||
console.error(err); | ||
} finally { | ||
setSending(false); | ||
} | ||
}, [message, sent]); | ||
|
||
return ( | ||
<FeedbackSenderWrapper> | ||
<Input.TextArea | ||
disabled={sent || sending} | ||
value={message} | ||
rows={3} | ||
placeholder="์ด๊ณณ์ ํผ๋๋ฐฑ ๋ด์ฉ์ ์ ๋ ฅํด์ฃผ์ธ์. ์์ฑํด์ฃผ์ ์์คํ ํผ๋๋ฐฑ์ด ๋ ์ข์ ์ฃผ์๊ฒ์์ ๋ง๋ค์ด์!" | ||
onChange={(ev) => setMessage(ev.target.value)} | ||
/> | ||
<Button disabled={sent || sending || !message} type="primary" onClick={handleSendClick}> | ||
{!sent ? "๋ณด๋ด๊ธฐ ๐" : "ํผ๋๋ฐฑ ์ ๋ฌ ์๋ฃ! ๐"} | ||
</Button> | ||
</FeedbackSenderWrapper> | ||
); | ||
}; | ||
|
||
export const FeedbackPopover = () => { | ||
return ( | ||
<Popover | ||
placement="top" | ||
overlayStyle={PopoverContentStyle} | ||
title={<PopoverTitle>ํผ๋๋ฐฑ ๋ณด๋ด๊ธฐ</PopoverTitle>} | ||
content={<FeedbackForm />} | ||
> | ||
<Typography.Text keyboard>ํผ๋๋ฐฑ ๋ณด๋ด๊ธฐ</Typography.Text> | ||
</Popover> | ||
); | ||
}; |