Skip to content
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

[허우림] week14 #413

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1181a3c
refactor(mentor): useMemo 훅 사용 함수명 명사 변경, interface명 및 선언문 중첩없게 변경
grapefruit13 Jan 17, 2024
6f6c27d
chore: jsx문에서 single quote 사용하도록 eslint / prettier 설정
grapefruit13 Jan 17, 2024
827d353
refactor(mentor) : setKeyword에 객체로 state 값 저장하던 것 수정, single quote로 코…
grapefruit13 Jan 17, 2024
10c8d88
refactor(mentor): isEyeClicked ->isPasswordVisible로 변경, input value를 …
grapefruit13 Jan 17, 2024
072b67d
refactor(mentor): 검색키워드 보여주는 컴포넌트에서 keyword context에서 불러오도록 수정
grapefruit13 Jan 17, 2024
1beb049
refactor(mentor): authInfo와 errorMsg를 하나의 state로 통합, signin/signup 함수…
grapefruit13 Jan 17, 2024
7364c52
refactor(mentor): signin/signup 함수명 변경, try catch 문의 error 발생시 alert …
grapefruit13 Jan 17, 2024
93f99de
refactor(mentor): context 파일들 tsx로 변경, 타입 지정
grapefruit13 Jan 17, 2024
ef79929
chore: react-hook-form 라이브러리 설치
grapefruit13 Jan 19, 2024
b8eb305
chore: pages/shared.tsx 삭제 후 pages/shared/index.tsx 추가
grapefruit13 Jan 19, 2024
fda532d
refactor: localStorage를 불러올 수 없을 때 null 반환하도록 처리
grapefruit13 Jan 21, 2024
9cbf0e0
feat: axios instance 생성 및 headers 설정, api 요청 별로 함수 생성
grapefruit13 Jan 21, 2024
c31f92b
chore: img url에 맞게 next.config 설정
grapefruit13 Jan 21, 2024
fbba917
feat: folder 페이지에서 14주차 요구사항 구현([id] 페이지 라우터 제외)
grapefruit13 Jan 21, 2024
5ebe569
refactor: context.tsx의 타입 오류 때문에 일시적으로 jsx로 수정하여 사용
grapefruit13 Jan 21, 2024
7e1088f
chore: double quote 부분 single quote로 코드 포맷 변경
grapefruit13 Jan 21, 2024
3840261
refactor: props에 타입설정, props 기본 값 삭제
grapefruit13 Jan 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
"createDefaultProgram": true
},
"env": {
"browser": true,
"browser": true,
"node": true,
"es6": true
},
"ignorePatterns": ["node_modules/"],
"ignorePatterns": ["node_modules/"],
"extends": [
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
"prettier"
],
"rules": {
"jsx-quotes": ["error", "prefer-single"],
"react/react-in-jsx-scope": "off",
"react/jsx-filename-extension": ["warn", { "extensions": [".ts", ".tsx"] }],
"no-useless-catch": "off"
"no-useless-catch": "off"
}
}
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
24 changes: 11 additions & 13 deletions components/common/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import NoImg from '@/public/assets/icons/card/card_no-img.svg';
import kebab from '@/public/assets/icons/card/kebab.svg';
import styles from '@/styles/card/card.module.css';

interface Link {
link: {
id: string;
createdAt: string;
url: string;
title: string;
description: string;
imageSource: string;
};
interface LinkProps {
id: string;
createdAt: string;
url: string;
title: string;
description: string;
imageSource: string;
}

export default function Card({ link }: Link) {
export default function Card({ link }: { link: LinkProps }) {
const { id, createdAt, url, title, description, imageSource } = link;
const [linkInfo, setLinkInfo] = useState({
id: '',
Expand All @@ -43,7 +41,7 @@ export default function Card({ link }: Link) {
});
};

const getCreatedAt = useMemo(() => {
const yearMonthDay = useMemo(() => {
const [year, month, day] = calCreatedDates(createdAt);
setMins(calCreatedAt(year, month, day));
return { year, month, day };
Expand All @@ -57,7 +55,7 @@ export default function Card({ link }: Link) {
<KebabContextProvider>
<div className={styles.flexWrapper} id={`card-${id}`}>
<div className={styles.cardImgWrapper}>
<Link target="_blank" href={url}>
<Link target='_blank' href={url}>
{imageSource ? (
<Image
className={
Expand Down Expand Up @@ -92,7 +90,7 @@ export default function Card({ link }: Link) {
imgSrc={kebab}
title={title}
description={description}
createdDates={getCreatedAt}
createdDates={yearMonthDay}
linkInfo={linkInfo}
/>
</div>
Expand Down
24 changes: 9 additions & 15 deletions components/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@ import LoginButton from '@/components/common/LoginButton';
import Logo from '@/components/common/Logo';
import styles from '@/styles/header/header.module.css';

interface Props {
profileData: {
id: number;
created_at?: string;
name: string;
image_source: string;
email: string;
auth_id?: string;
};
interface HeaderProps {
id: number;
created_at?: string;
name: string;
image_source: string;
email: string;
auth_id?: string;
}

export default function Header({ profileData }: Props) {
const {
name = 'defaultName',
image_source = 'https://images.unsplash.com/photo-1701600713610-0f724c65168d?q=80&w=1074&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
email = '[email protected]',
} = profileData;
export default function Header({ profileData }: { profileData: HeaderProps }) {
const { id, created_at, name, image_source, email, auth_id } = profileData;

return (
<div className={styles.header}>
Expand Down
14 changes: 7 additions & 7 deletions components/common/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export default function SearchBar() {

const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'Backspace' && router.query.keyword === '') {
setKeyword(router.query);
setKeyword(router.query.keyword);
}
if (e.key === 'Enter') {
setKeyword(router.query);
setKeyword(router.query.keyword);
if (!router.query.keyword) return;
setIsSearchResultShowed(true);
}
Expand Down Expand Up @@ -59,19 +59,19 @@ export default function SearchBar() {
className={`${styles.searchbarInput} ${
isSearchActive ? styles.active : styles.inactive
}`}
name="keyword"
type="text"
placeholder="링크를 검색해 보세요."
name='keyword'
type='text'
placeholder='링크를 검색해 보세요.'
onChange={(e) => handleKeywordChange(e)}
onKeyDown={(e) => handleKeyDown(e)}
/>
<button onClick={handleButtonClick}>
<Image
className={styles.closeButton}
src="/assets/icons/search/close.svg"
src='/assets/icons/search/close.svg'
width={24}
height={24}
alt="reset-addLink"
alt='reset-addLink'
/>
</button>
</div>
Expand Down
16 changes: 7 additions & 9 deletions components/common/SearchResult.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { useRouter } from 'next/router';
import { useContext } from 'react';
import FolderContext from '@/contexts/FolderContext';
import styles from '@/styles/search/searchResult.module.css';

export default function SearchResult() {
const router = useRouter();
const search = router.query.keyword;
const { keyword } = useContext(FolderContext);

return (
<>
<span className={styles.resultMessage}>
<span className={styles.keyword}>{search}</span>
<span className={styles.sub}>으로 검색한 결과입니다.</span>
</span>
</>
<span className={styles.resultMessage}>
<span className={styles.keyword}>{keyword}</span>
<span className={styles.sub}>으로 검색한 결과입니다.</span>
</span>
);
}
34 changes: 18 additions & 16 deletions components/common/auth/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,39 @@ import styles from '@/styles/auth/auth.module.css';

export default function Input({
type,
name,
placeholder,
onClick,
onBlurInput,
errorMsg,
}: {
type: string;
name?: string;
placeholder: string;
onClick?: any;
onBlurInput: (value: string) => any;
errorMsg: string;
}) {
const [isEyeClicked, setIsEyeClicked] = useState(false);
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
const [inputValue, setInputValue] = useState('');

const handleEyeClick = () => {
setIsEyeClicked((prev) => !prev);
setIsPasswordVisible((prev) => !prev);
};

const handleOnBlur = (e: React.FocusEvent<HTMLInputElement, Element>) => {
onBlurInput(e.target.value);
const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value);
};

const handleOnBlur = () => {
onBlurInput(inputValue);
};

return (
<>
<div className={styles.inputBox}>
<input
placeholder={placeholder}
onBlur={(e) => handleOnBlur(e)}
onChange={(e) => handleOnChange(e)}
onBlur={handleOnBlur}
name={type}
type={type === 'password' && isEyeClicked ? 'text' : type}
type={type === 'password' && isPasswordVisible ? 'text' : type}
className={
errorMsg
? `${styles.textfieldInput} ${styles.errorInput}`
Expand All @@ -43,23 +45,23 @@ export default function Input({
/>
{type === 'password' && (
<button
type="button"
type='button'
className={styles.eyeToggleButton}
onClick={handleEyeClick}
>
{isEyeClicked ? (
{isPasswordVisible ? (
<Image
src="/assets/icons/auth/eye-on.svg"
src='/assets/icons/auth/eye-on.svg'
width={16}
height={16}
alt="eye-on"
alt='eye-on'
/>
) : (
<Image
src="/assets/icons/auth/eye-off.svg"
src='/assets/icons/auth/eye-off.svg'
width={16}
height={16}
alt="eye-off"
alt='eye-off'
/>
)}
</button>
Expand Down
4 changes: 2 additions & 2 deletions components/common/folderPage/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export default function Dropdown({
<div className={styles.container}>
{clickedKebabOption.delete && (
<Modal
title="링크 삭제"
title='링크 삭제'
subtitle={linkInfo.url}
button={{ color: 'red', text: '삭제하기' }}
closeKebab={closeKebab}
/>
)}
{clickedKebabOption.addToFolder && (
<Modal
title="폴더에 추가"
title='폴더에 추가'
button={{ color: 'blue', text: '추가하기' }}
subtitle={linkInfo.url}
closeKebab={closeKebab}
Expand Down
10 changes: 2 additions & 8 deletions contexts/FolderContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ const FolderContext = createContext();

export function FolderContextProvider({ children }) {
const [folderList, setFolderList] = useState([]);
const [clickedOption, setClickedOption] = useState({
addFolderLink: false,
shareFolder: false,
editFolderName: false,
deleteFolder: false,
addNewFolder: false,
});
const [clickedOption, setClickedOption] = useState({});
const [addedLink, setAddedLink] = useState('');
const [keyword, setKeyword] = useState('');
const [filteredLinks, setFilteredLinks] = useState([]);
Expand All @@ -21,8 +15,8 @@ export function FolderContextProvider({ children }) {
value={{
clickedOption,
setClickedOption,
setAddedLink,
addedLink,
setAddedLink,
folderList,
setFolderList,
keyword,
Expand Down
Loading
Loading