Skip to content

Commit

Permalink
Merge branch 'frontend' of https://github.com/Kernel360/F2-TECHPICK i…
Browse files Browse the repository at this point in the history
…nto front/feat/#612
  • Loading branch information
dmdgpdi committed Nov 29, 2024
2 parents ec4a21c + 9a8521c commit 11860c3
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 18 deletions.
2 changes: 2 additions & 0 deletions frontend/techpick/src/apis/apiConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const API_ENDPOINTS = {
TAGS: 'tags',
LINKS: 'links',
SHARED: 'shared',
LOGOUT: 'logout',
};

export const API_URLS = {
Expand Down Expand Up @@ -37,4 +38,5 @@ export const API_URLS = {
GET_PICK_BY_URL: (url: string) => `${API_ENDPOINTS.PICKS}/link?link=${url}`,
GET_LINK_OG_DATA: (url: string) => `${API_ENDPOINTS.LINKS}?url=${url}`,
SHARE_FOLDER: API_ENDPOINTS.SHARED,
POST_LOGOUT: `${API_ENDPOINTS.LOGOUT}`,
};
1 change: 0 additions & 1 deletion frontend/techpick/src/apis/auth/index.ts

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/techpick/src/apis/auth/queryFunctions.ts

This file was deleted.

6 changes: 0 additions & 6 deletions frontend/techpick/src/apis/auth/useLogout.ts

This file was deleted.

16 changes: 16 additions & 0 deletions frontend/techpick/src/apis/postLogout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { HTTPError } from 'ky';
import { apiClient } from '@/apis/apiClient';
import { API_URLS } from './apiConstants';
import { returnErrorFromHTTPError } from './error';

export const postLogout = async () => {
try {
await apiClient.post(API_URLS.POST_LOGOUT);
} catch (httpError) {
if (httpError instanceof HTTPError) {
const error = await returnErrorFromHTTPError(httpError);
throw error;
}
throw httpError;
}
};
31 changes: 31 additions & 0 deletions frontend/techpick/src/app/(signed)/mypage/page.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { style } from '@vanilla-extract/css';
import { colorVars } from 'techpick-shared';

export const myPageLayoutStyle = style({
width: '100%',
height: '100vh',
padding: '12px',
backgroundColor: colorVars.gold2,
});

export const buttonSectionLayout = style({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100%',
});

export const logoutButtonStyle = style({
width: '120px',
height: '32px',
border: '1px solid',
borderColor: colorVars.red8,
borderRadius: '4px',
transition: 'background-color 0.3s ease',
color: colorVars.red11,
cursor: 'pointer',

':hover': {
backgroundColor: colorVars.red3,
},
});
30 changes: 30 additions & 0 deletions frontend/techpick/src/app/(signed)/mypage/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client';

import { postLogout } from '@/apis/postLogout';
import { ROUTES } from '@/constants';
import {
buttonSectionLayout,
logoutButtonStyle,
myPageLayoutStyle,
} from './page.css';

export default function MyPage() {
const handleLogout = async () => {
try {
await postLogout();
window.location.replace(ROUTES.LOGIN);
} catch {
/* empty */
}
};

return (
<div className={myPageLayoutStyle}>
<div className={buttonSectionLayout}>
<button className={logoutButtonStyle} onClick={handleLogout}>
로그아웃
</button>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const folderNameStyle = style({
display: 'inline-block',
fontWeight: fontWeights['medium'],
fontSize: fontSize['3xl'],
height: '40px',
height: '48px',
lineHeight: '48px',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
Expand Down
18 changes: 18 additions & 0 deletions frontend/techpick/src/components/FolderTree/UserMenuBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Link from 'next/link';
import { CircleUserRoundIcon, SearchIcon } from 'lucide-react';
import { ROUTES } from '@/constants';
import { userMenuBarLayoutStyle } from './userMenuBar.css';

export function UserMenuBar() {
return (
<div className={userMenuBarLayoutStyle}>
<Link href={ROUTES.MY_PAGE}>
<CircleUserRoundIcon />
</Link>

<button>
<SearchIcon />
</button>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ export const folderTextStyle = style({
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
height: '24px',
height: '28px',
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export const folderTreeHeaderLayout = style({
position: 'sticky',
top: 0,
minWidth: sizes['6xs'],
paddingTop: '12px',
backgroundColor: colorVars.sand2,
});

Expand Down
2 changes: 2 additions & 0 deletions frontend/techpick/src/components/FolderTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { HorizontalResizableContainer } from './HorizontalResizableContainer';
import { ShowCreateFolderInputButton } from './ShowCreateFolderInputButton';
import { treeLayout, treeNodeLayoutStyle } from './tree.css';
import { TreeNode } from './TreeNode';
import { UserMenuBar } from './UserMenuBar';

export function FolderTree() {
const { newFolderParentId } = useCreateFolderInputStore();
Expand All @@ -24,6 +25,7 @@ export function FolderTree() {
return (
<HorizontalResizableContainer>
<div className={treeLayout}>
<UserMenuBar />
<FolderTreeHeader />

<div className={folderTreeHeaderTitleLayout}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/techpick/src/components/FolderTree/tree.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const resizeHandleStyle = style({
export const treeLayout = style({
height: '100vh',
padding: '12px',
paddingTop: '0',
paddingTop: '24px',
backgroundColor: colorVars.sand2,

'@media': {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { style } from '@vanilla-extract/css';

export const userMenuBarLayoutStyle = style({
display: 'flex',
justifyContent: 'space-between',
marginLeft: '12px',
marginRight: '8px',
});
1 change: 1 addition & 0 deletions frontend/techpick/src/constants/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export const ROUTES = {
FOLDER_DETAIL: (folderId: number) => `/folders/${folderId}`,
SEARCH: '/folders/search',
LOGIN: '/login',
MY_PAGE: '/mypage',
};
2 changes: 1 addition & 1 deletion frontend/techpick/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async function middleware(req: NextRequest) {
const isAuthenticated = !!req.cookies.get('access_token');

const unauthenticatedOnlyPaths = ['/login'];
const authenticatedOnlyPaths = ['/folders', '/'];
const authenticatedOnlyPaths = ['/folders', '/', '/mypage'];

const isUnauthenticatedOnlyPath = unauthenticatedOnlyPaths.includes(pathname);
const isAuthenticatedOnlyPath = authenticatedOnlyPaths.some((path) =>
Expand Down
2 changes: 1 addition & 1 deletion frontend/techpick/src/styles/reset.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ globalStyle(
);

globalStyle('body', {
lineHeight: 1,
lineHeight: 1.5,
fontSize: '16px',
});

Expand Down

0 comments on commit 11860c3

Please sign in to comment.