Skip to content

Commit

Permalink
Merge pull request #45 from teamViNO/feature-022
Browse files Browse the repository at this point in the history
refactor-022 : search api any 제거
  • Loading branch information
whistleJs authored Feb 8, 2024
2 parents 20a5614 + 22b808b commit 06283cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/apis/search.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { APIResponse } from '@/models/config/axios';
import axios from './config/instance';
import { ResponseSearch } from '@/models/search';

const PREFIX = '/search';

export const searchAPI = (type : string, keyword : string) => {
const paramType = type === 'keyword' ? 'keywordName' : 'hashtagName';
return axios.get<APIResponse<any>>(PREFIX + `/${type}/`, {
return axios.get<APIResponse<ResponseSearch>>(PREFIX + `/${type}/`, {
params : {[paramType] : keyword}
});
}
2 changes: 1 addition & 1 deletion src/components/SearchPage/SearchResultBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IVideo } from '@/models/search';
import Styled from '@/styles/SearchResult';
import React, { ImgHTMLAttributes } from 'react';
import React from 'react';

interface SearchResultBoxProp {
video : IVideo
Expand Down
4 changes: 4 additions & 0 deletions src/models/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ export interface IVideo {
user : string;
tag : IName[];
}

export interface ResponseSearch {
videos : IVideo[];
}
2 changes: 1 addition & 1 deletion src/pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const SearchPage = () => {
const [tags, setTags] = useState<string[]>([]);
const [input, setInput] = useState<string>('');
const [searchType, setSearchType] = useState(true); // True : keyword | False : hashTag
const [userHashTag, SetUserHashTag] = useState<string[]>(["기획", "광고", "마케팅", "트렌드", "기업", "광고", "마케팅", "트렌드", "기업", "광고"]); // 사용자의 해시태그 데이터 10개 <임의 데이터>
const userHashTag = ["기획", "광고", "마케팅", "트렌드", "기업", "광고", "마케팅", "트렌드", "기업", "광고"]; // 사용자의 해시태그 데이터 10개 <임의 데이터>
const [selectedHashtags, setSelectedHashtags] = useState<string[]>([]);
const searchNav = useNavigate();

Expand Down

0 comments on commit 06283cb

Please sign in to comment.