-
Notifications
You must be signed in to change notification settings - Fork 26
[정상인] sprint9 #142
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
[정상인] sprint9 #142
The head ref may contain hidden characters: "Next-\uC815\uC0C1\uC778-sprint9"
Conversation
…Sprint-Mission into Next-정상인-sprint9
|
스프리트 미션 하시느라 수고 많으셨어요. |
앞으로 App router를 사용할 일이 많을 것 같아서 복습 겸 page router를 사용했습니다.크으 ~ 좋습니다 ! 심화 프로젝트 시작 전에 감을 유지하기 위해서 요구사항만 정말 가볍게 만들었습니다. 순한 맛으로 부탁드려요 ㅠㅠ ^^;넵넵 ~! ㅎㅎㅎ 참고해서 리뷰하도록 하겠습니다 ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
크으 ~ Axios 세팅이 깔끔하고 좋네요 👍
| interface PostTodoRequest { | ||
| name: string; | ||
| } | ||
|
|
||
| export interface PostTodoResponse extends TodoItem { | ||
| tenantId: string; | ||
| memo: string; | ||
| imageUrl: string; | ||
| } | ||
|
|
||
| export const postTodo = async ({ | ||
| name, | ||
| }: PostTodoRequest): Promise<PostTodoResponse> => { | ||
| return instance.post("/items", { name }); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿 ! 응답과 요청 타입을 정의하셨군요 !
이제 타입스크립트에 완전 적응하신게 느껴집니다 👍👍👍👍
| return ( | ||
| <span | ||
| className={`${styles.badge} ${styles[variants]} ${className ?? ""}`} | ||
| aria-label={variantsToLabel[variants]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호 aria-label도 신경쓰셨군요 ? 👐
| const variantsToLabel = { | ||
| todo: "TO DO", | ||
| done: "DONE", | ||
| }; | ||
|
|
||
| interface BadgeProps { | ||
| variants: keyof typeof variantsToLabel; | ||
| className?: string; | ||
| } | ||
|
|
||
| const Badge = ({ variants, className }: BadgeProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(의견/선택) Badge는 흔히 사용되는 유저 인터페이스예요 !
근데 지금 정의하신걸 보니까 해당 뱃지는 공통으로 사용되는 흔한 뱃지가 아니라 상태에 대한 뱃지를 표현하고 있는 것으로 보이는군요?
StatusBadge와 같이 네이밍을 해도 괜찮을 것 같습니다 !
| export const getServerSideProps = async () => { | ||
| try { | ||
| const response = await getTodos(); | ||
| return { | ||
| props: { | ||
| todos: response, | ||
| }, | ||
| }; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
크으 ~ 적절한 SSR 활용이네요 👍
이렇게 되면 페이지를 그려주는 속도가 훨씬 빠르겠어요 👍
| <search> | ||
| <form className={styles.form} onSubmit={onSubmit}> | ||
| <input | ||
| className={`${styles.input} font-regular-16`} | ||
| value={value} | ||
| onChange={onChange} | ||
| type="text" | ||
| placeholder="할 일을 입력해주세요" | ||
| /> | ||
| <Button variants="append" type="submit" disabled={isDisabled} /> | ||
| </form> | ||
| </search> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
크으 ~ HTML에 대해서 꼼꼼히 공부하신게 느껴집니다.
와우 search 태그를 쓰시는 수강생님은 처음 봤어요 👍👍👍
영역에 대한 의미가 확실하네요 훌륭합니다
| const [isDisabled, setIsDisabled] = useState(false); | ||
|
|
||
| const completedTodos: TodoItem[] = []; | ||
| const pendingTodos: TodoItem[] = []; | ||
|
|
||
| todos.forEach((todo) => { | ||
| if (todo.isCompleted) completedTodos.push(todo); | ||
| else pendingTodos.push(todo); | ||
| }); | ||
|
|
||
| const handleSearchTermSubmit = async (e: FormEvent<HTMLFormElement>) => { | ||
| e.preventDefault(); | ||
| setIsDisabled(true); | ||
| try { | ||
| await postTodo({ name: searchTerm }); | ||
| const updatedTodos = await getTodos(); | ||
| setTodos(updatedTodos); | ||
| setSearchTerm(""); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } finally { | ||
| setIsDisabled(false); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
만약 중복 요청을 방지하는 거라면 disabled 상태를 제거하고 useTransition을 사용해볼 수 있습니다 !
다음과 같이 사용해볼 수 있어요 !
const [isPending, startTransition] = useTransition();
const handleSearchTermSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
startTransition(async () => {
try {
await postTodo({ name: searchTerm });
const updatedTodos = await getTodos();
setTodos(updatedTodos);
setSearchTerm("");
} catch (error) {
console.error(error);
}
});
};|
크으 ~ 수고하셨습니다 상인님 ! |
요구사항
기본
스크린샷
멘토에게