Skip to content

Commit

Permalink
fix: lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewoook committed Jun 23, 2024
1 parent ef3dd3d commit 7398101
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 80 deletions.
79 changes: 0 additions & 79 deletions src/components/FeedbackPopover.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/ui/AddressList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import styled from "styled-components";
// import "./AddressList.css";
import type { AddressData } from "@/shared/models/address";
import { ClickToCopyText } from "../ClickToCopyText";
import { FeedbackPopover } from "../../FeedbackPopover";
import { FeedbackPopover } from "../FeedbackPopover";
import type { DisplayOptions } from "@/shared/models/settings";

interface Props extends DisplayOptions {
Expand Down
82 changes: 82 additions & 0 deletions src/components/ui/FeedbackPopover.tsx
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="์ด๊ณณ์— ํ”ผ๋“œ๋ฐฑ ๋‚ด์šฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.&#10;์ž‘์„ฑํ•ด์ฃผ์‹  ์†Œ์ค‘ํ•œ ํ”ผ๋“œ๋ฐฑ์ด ๋” ์ข‹์€ ์ฃผ์†Œ๊ฒ€์ƒ‰์„ ๋งŒ๋“ค์–ด์š”!"
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>
);
};

0 comments on commit 7398101

Please sign in to comment.