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

[박상준] Week15 #476

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bbc1f6d
fix: 인풋사용하는 컴포넌트 react-hook-form으로 변경
sj0724 May 20, 2024
8561791
fix: 메인페이지 이미지태그로 변경
sj0724 May 20, 2024
d64a7fe
fix: 모달동작시 동작 로직 수정
sj0724 May 20, 2024
c10ef9a
fix: axios intercepros 적용, 토큰 자동 기입
sj0724 May 21, 2024
f8122ea
feat: 폴더 이동시 쿼리 변경, 퀴리값 사용해서 폴더 링크 로딩, 존재하지 않는 폴더 요청시 페이지 구성
sj0724 May 21, 2024
3113144
feat: kebab 외부 클릭시 kebab 닫기 구현
sj0724 May 22, 2024
1466e44
fix: 동적 라우팅, 옵셔널 세그먼트로 변경
sj0724 May 23, 2024
a189e41
fix: card 컴포넌트 Image태그로 최적화
sj0724 May 23, 2024
6086486
fix: 이미지 태그로 변경
sj0724 May 23, 2024
48461bf
fix: 옵저버 인식 안되는 버그수정
sj0724 May 23, 2024
43f6c23
fix: notfound 컴포넌트 구현 카드 컴포넌트 css 수정
sj0724 May 23, 2024
c59d505
fix: card 컴포넌트 이미지파일로 수정 및 css 수정
sj0724 May 24, 2024
f7b0de1
feat: 링크 복사 기능 구현
sj0724 May 24, 2024
c5e2154
feat: 폴더 공유시 toast구현
sj0724 May 24, 2024
bbfe19b
fix: 이미지 경로 404일때 로고 표시
sj0724 May 24, 2024
c3c79cd
feat: 쿼리파라미터로 유저 정보 조회 구현
sj0724 May 24, 2024
9f817c8
feat: kakao 공유하기 구현
sj0724 May 24, 2024
2d1c86c
feat: facebook 공유 기능 구현
sj0724 May 24, 2024
d29c8fd
fix: 코드리뷰 사항 수정
sj0724 May 24, 2024
57c9514
fix: 메인 섹션 카드 css수정
sj0724 May 24, 2024
8325141
fix: 메인 페이지, 로그인, 회원가입 반응형 수정
sj0724 May 26, 2024
5a88f7d
fix: 폴더 페이지 접근시 토큰없으면 메인 이동, 버튼 반응형 수정
sj0724 May 26, 2024
4611416
fix: 케밥 위치 조정
sj0724 May 26, 2024
74c431b
fix: 링크 삭제시 다른 링크 삭제되는 버그 수정
sj0724 May 26, 2024
6042f20
feat: 폴더 이름 변경 기능 구현
sj0724 May 26, 2024
6196cc7
fix: 파일 수정 확인용 커밋
sj0724 May 26, 2024
70c346c
fix: env파일 수정
sj0724 May 26, 2024
bcc48ac
feat: 로딩 컴포넌트 구현
sj0724 May 27, 2024
df5ea65
fix: 검색기능 옵셔널 체이닝으로 변경
sj0724 May 27, 2024
64b7386
fix: shared 페이지 라우터 쿼리에서 userid값 제거
sj0724 May 28, 2024
12719d7
fix: card css수정
sj0724 May 28, 2024
1015c20
fix: 폴더 추가, 링크 검색 글자수 제한 설정
sj0724 May 28, 2024
297e423
fix: prerender시점에서 css도 포함해서 렌더링하도록 설정
sj0724 May 28, 2024
e865644
fix: 레이아웃 쉬프트 방지 및 메인 페이지 이미지 css수정
sj0724 May 28, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-error.log*

# local env files
.env*.local
.env
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.vscode 폴더도 추가해주세요~!


# vercel
.vercel
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["Linkbrary"]
}
5 changes: 5 additions & 0 deletions @types/import-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace NodeJS {
interface ProcessEnv {
NEXT_PUBLIC_BASE_URL: string;
}
}
12 changes: 1 addition & 11 deletions Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@ import React, { ReactElement, useEffect, useState } from 'react';
import { createPortal } from 'react-dom';

const ModalPortal = ({ children }: { children: ReactElement }) => {
const [mounted, setMounted] = useState<boolean>(false);
const [portalElement, setPortalElement] = useState<HTMLElement | null>(null);

useEffect(() => {
setPortalElement(document.getElementById('modal'));
}, []);

useEffect(() => {
setMounted(true);
return () => setMounted(false);
}, []);

return (
<>
{mounted && portalElement ? createPortal(children, portalElement) : null}
</>
);
return <>{portalElement ? createPortal(children, portalElement) : null}</>;
};

export default ModalPortal;
102 changes: 59 additions & 43 deletions pages/api/api.ts → api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import axios from '../../instance/instance';
import axios from '../instance/instance';

axios.interceptors.request.use(
(config) => {
const accessToken = localStorage.getItem('token');
config.headers['Authorization'] = accessToken;

return config;
},
(error) => {
console.log(error);
return Promise.reject(error);
}
);

Comment on lines +3 to +14
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헤더 값을 일괄적으로 적용해주셨네요 👍

export async function getSampleUser() {
try {
Expand Down Expand Up @@ -49,7 +62,17 @@ export async function getFolder(id: string) {
}
}

export async function getFolderList(id: string, folderId: number) {
export async function getFolderData(folderId: string) {
try {
const { data } = await axios.get(`/folders/${folderId}`);
return data.data;
} catch (error) {
console.error('Error fetching folder:', error);
throw error;
}
}

export async function getFolderList(id: string, folderId: string) {
if (folderId) {
try {
const query = `/${id}/links?folderId=${folderId}`;
Expand Down Expand Up @@ -85,14 +108,23 @@ export async function getUser(accessToken: string) {
}
}

export async function getUserData(id: string) {
try {
const { data } = await axios.get(`/users/${id}`);
return data.data;
} catch (error) {
console.error('Error fetching user:', error);
throw error;
}
}

export async function postSignIn(id: string, password: string) {
try {
const { data } = await axios.post('/sign-in', {
email: id,
password: password,
});
localStorage.setItem('token', data.data.accessToken);
window.location.href = '/';
return data;
} catch (error) {
console.error('Error fetching sign-in:', error);
Expand Down Expand Up @@ -120,7 +152,6 @@ export async function postSignUp(id: string, password: string) {
});
localStorage.setItem('token', data.data.accessToken);
alert('회원가입이 완료되었습니다!');
window.location.href = '/';
return data;
} catch (error) {
console.error('Error fetching sign-in:', error);
Expand All @@ -130,53 +161,31 @@ export async function postSignUp(id: string, password: string) {

export async function postFolder(name: string) {
try {
const token = localStorage.getItem('token');
const { data } = await axios.post(
'/folders',
{
name: name,
},
{
headers: {
Authorization: token,
},
}
);
return data;
const { data } = await axios.post('/folders', {
name: name,
});
return data.data;
} catch (error) {
console.error('Error fetching post folder:', error);
}
}

export async function deleteFolder(folderId: number) {
export async function deleteFolder(folderId: string) {
try {
const token = localStorage.getItem('token');
const { data } = await axios.delete(`/folders/${folderId}`, {
headers: {
Authorization: token,
},
});
const { data } = await axios.delete(`/folders/${folderId}`);
return data;
} catch (error) {
console.error('Error fetching post folder:', error);
}
}

export async function postLink(folderId: number, url: string) {
export async function postLink(folderId: string, url: string) {
try {
const token = localStorage.getItem('token');
const { data } = await axios.post(
'/links',
{
url: url,
folderId: folderId,
},
{
headers: {
Authorization: token,
},
}
);
const { data } = await axios.post('/links', {
url: url,
folderId: folderId,
});
return data;
} catch (error) {
alert('url과 폴더를 지정해주세요!');
Expand All @@ -186,14 +195,21 @@ export async function postLink(folderId: number, url: string) {

export async function deleteLink(linkId: number) {
try {
const token = localStorage.getItem('token');
const { data } = await axios.delete(`/links/${linkId}`, {
headers: {
Authorization: token,
},
});
const { data } = await axios.delete(`/links/${linkId}`);
return data;
} catch (error) {
console.error('Error fetching post folder:', error);
}
}

export async function putFolder(folderId: string, name: string) {
try {
const { data } = await axios.put(`/folders/${folderId}`, {
name: name,
});
return data;
} catch (error) {
alert('이름 수정에 실패했습니다!');
console.error('Error fetching put folder:', error);
}
}
3 changes: 3 additions & 0 deletions components/Button/Button.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ export const Cta = styled.button<ButtonProps>`
line-height: normal;
width: ${({ size }) => buttonSize[size]}rem;
position: relative;
white-space: nowrap;

&:hover {
opacity: 0.8;
}

@media (max-width: 768px) {
font-size: 1.4rem;
padding: 1rem 1.6rem;
width: ${({ size }) => (size === 'lg' ? '100%' : `${buttonSize[size]}rem`)};
}
`;
74 changes: 43 additions & 31 deletions components/Card/Card.styled.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
import styled from 'styled-components';

export const EmptyImg = styled.div`
height: 100%;
background-color: var(--EmptyArea);
border-radius: 1.5rem 1.5rem 0 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;

img {
opacity: 0.2;
width: 13.3rem;
height: 2.4rem;
}
`;

export const ItemImg = styled.div<{ image: string }>`
height: 100%;
background-image: url(${(props) => props.image});
border-radius: 1.5rem 1.5rem 0 0;
background-size: cover;
background-position: center;

&:hover {
background-size: 150%;
}
`;

export const ItemCard = styled.div`
width: 34rem;
height: 33.4rem;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0px 5px 25px 0px rgba(0, 0, 0, 0.08);
border-radius: 1.5rem;
text-decoration: none;
Expand All @@ -49,21 +21,61 @@ export const ItemCard = styled.div`
}
`;

export const StarIcon = styled.img`
export const StarIcon = styled.div`
width: 3.4rem;
height: 3rem;
flex-shrink: 0;
position: absolute;
top: 1.5rem;
right: 1.5rem;
z-index: 1;
`;

export const EmptyImg = styled.div`
height: 100%;
width: 100%;
background-color: var(--EmptyArea);
border-radius: 1.5rem 1.5rem 0 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;

img {
opacity: 0.2;
}
`;

export const ItemImg = styled.div`
position: relative;
transition: 0.3s ease;
width: 100%;
height: 100%;
img {
object-fit: cover;
}

&:hover {
width: 170%;
}
`;

export const ImageArea = styled.div`
border-radius: 1.5rem 1.5rem 0 0;
height: 23.5rem;
width: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
`;

export const ItemInfo = styled.div`
display: flex;
flex-direction: column;
padding: 1.5rem 2rem;
width: 100%;
height: 13.5rem;
height: 10.5rem;
gap: 1rem;
position: relative;
`;
Expand Down
Loading
Loading