Skip to content

Commit

Permalink
refactor: 불필요한 코드 제거 및 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonjinan096 committed Jul 8, 2024
1 parent 4e869c7 commit 5e821bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/(post)/search/_components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { ChangeEvent, useState } from 'react';

import Icon from '@/src/components/Icon';
import TextInput from '@/src/components/TextInput';
Expand All @@ -11,7 +11,7 @@ interface SearchBarProps {
const SearchBar = ({ onClear, onSubmit }: SearchBarProps) => {
const [input, setInput] = useState('');

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
setInput(e.target.value);
};

Expand Down
5 changes: 1 addition & 4 deletions src/app/(post)/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState } from 'react';

import Link from 'next/link';
import { useRouter, useSearchParams } from 'next/navigation';
import { useSearchParams } from 'next/navigation';

import { useGetPostListAPI } from '@/src/apis/postList';
import { CATEGORY_MAP } from '@/src/app/(main)/constants';
Expand All @@ -18,19 +18,16 @@ import SearchBar from './_components/SearchBar';

const SearchPostPage = () => {
const searchParams = useSearchParams();
const router = useRouter();
const channel = (searchParams.get('channel') as ChannelType | null) ?? 'all';
const [keyword, setKeyword] = useState('');
const { content: posts } = useGetPostListAPI(keyword, CATEGORY_MAP[channel]);

const handleRemoveClick = () => {
setKeyword('');
router.push(`/search`);
};

const handleSubmit = (input: string) => {
setKeyword(input);
router.push(`/search`);
};

return (
Expand Down

0 comments on commit 5e821bd

Please sign in to comment.