-
Notifications
You must be signed in to change notification settings - Fork 2
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
[#8] 워크스페이스 페이지 이동 기능, 워크스페이스 이름 변경 기능 구현 #100
Merged
Merged
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
11da411
✨ feat: 워크스페이스 요청 후 에러 발생 시 에러 발생을 알려주는 컴포넌트 추가
lee0jae330 e3f8d9e
✨ feat: 워크스페이스 불러오기 시 에러가 발생한 경우 에러 컴포넌트를 렌더링하도록 변경 및 api 호출 영역 렌더링 조…
lee0jae330 98eba36
🔨 refactor: 편집 시간 format 메소드 shared/utils로 분리
lee0jae330 6243f1e
✨ feat: WorkspaceItem에 onClick이라는 props 추가 및 카드 div 추가
lee0jae330 13187ee
✨ feat: 워크스페이스 item 클릭 시 workspace 페이지로 navigate 되도록 기능 추가
lee0jae330 de6006b
✨ feat: useGetWorkspaceList 반환값으로 isError를 리턴하도록 변경
lee0jae330 e953069
🙀 chore: 워크스페이스 조회 api 엔드포인트 변경 /workspace -> /workspace/list
lee0jae330 0568f46
🙀 chore: swagger 스키마 추가 WorkspaceIdResposne, WorkspaceListDto, NextCu…
lee0jae330 a7e8eb7
💬 comment: 워크스페이스 목록 조회 api swagger 주석 추가
lee0jae330 09a3475
🙀 chore: swagger-output.json gitignore에 추가
lee0jae330 df03708
Remove swagger-output.json from tracking
lee0jae330 bd503ff
✨ feat: 워크스페이스 하나만 조회하는 findWorkspaceByWorkspaceId 메소드 추가
lee0jae330 90405fe
✨ feat: GET /workspace?workspace=워크스페이스ID api 로직 추가
lee0jae330 1c836e4
✨ feat: 라우팅 추가 및 swagger 주석 추가
lee0jae330 4be5887
✨ feat: 404 에러 메세지 추가
lee0jae330 dc9c8e2
🙀 chore: 타입명 변경 TworkspaceDto => Tworkspace
lee0jae330 2dd32ba
✨ feat: 스웨거 WorkspaceDto 타입 추가
lee0jae330 d89e661
🙀 chore: find -> findOne 메소드 사용 및 workspace_id, name만 반환하도록 변경
lee0jae330 0a374a8
🙀 chore: 404 에러 조건 변경
lee0jae330 6537ed8
🙀 chore: findOne.projection 옵션 변경
lee0jae330 7c81b7b
🙀 chore: 스웨거 주석 수정
lee0jae330 6c5fca7
🙀 chore: UUID 패키지 설치
lee0jae330 245a669
✨ feat: crypto 모듈은 브라우저에서 지원이 안되는 문제가 있어 uuid 모듈로 변경
lee0jae330 5077a6f
✨ feat: workspace 정보 조회 시 응답 타입 정의
lee0jae330 8af70ca
✨ feat: 단일 워크스페이스의 정보 api 요청하는 useGetWorkspace 커스텀 추가
lee0jae330 b0accfd
✨ feat: 단일 워크스페이스 정보 조회 api 연동
lee0jae330 abc56be
✨ feat: WorkspacePageHeader, WorkspaceNameInput의 props 추가, 해당 props를 …
lee0jae330 94edaee
🙀 chore: EmptyWorkspace가 WorkspaceGrid 자식 컴포넌트로 동작할 시 디자인이 변경되는 문제가 있…
lee0jae330 b52224d
✨ feat: user_id, workspace_id 를 통해 document를 찾고 newName으로 해당 document…
lee0jae330 863831b
✨ feat: 이름 변경 요청 api 로직을 처리하는 메소드
lee0jae330 3fd9a4e
✨ feat: /workspace/name PATCH 라우팅 추가 및 스웨거 명세 작성
lee0jae330 ee4a152
✨ feat: PATCH /workspace/name 메서드 연동
lee0jae330 e506457
✨ feat: Workspace 정보를 관리하는 useWorkspaceStore 전역상태 커스텀 훅 추가
lee0jae330 64dcae1
✨ feat: useGetWorkspace 커스텀 훅으로 workspace의 정보를 요청할 시 성공하면 workspace 의…
lee0jae330 93a97a0
✨ feat: 워크스페이스 정보를 불러오는 것을 실패하면 NotFound 페이지를 렌더링함
lee0jae330 abbd5ea
🔨 refactor: workspace 정보를 전역 상태로 관리함에 따라 props 삭제
lee0jae330 3f352ac
✨ feat: 워크스페이스의 이름 변경을 요청하는 커스텀 훅 추가
lee0jae330 fd96c39
🙀 chore: index.ts re-export 추가
lee0jae330 133b876
✨ feat: 이름 변경 로직 추가, 이름 변경 요청 대기 시 input 창 비활성화 및 로딩 위젯 렌더링 기능 추가
lee0jae330 0b8e7a3
🎨 style: 토스트 메세지 위치 변경
lee0jae330 b4f7c67
Merge branch 'dev' into feat/8
lee0jae330 3c53efa
Update boolock-dev-cicd.yml
lee0jae330 d9aff79
🙀 chore: effect 임포트 변경
lee0jae330 b0040a4
Merge branch 'feat/8' of github.com:boostcampwm-2024/web31-BooLock in…
lee0jae330 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,33 @@ | ||
import TrashSVG from '@/shared/assets/trash.svg?react'; | ||
import { formatRelativeOrAbsoluteDate } from '@/shared/utils'; | ||
import { useModalStore } from '@/shared/store'; | ||
|
||
type WorkspaceItemProps = { | ||
title: string; | ||
thumbnail: string; | ||
lastEdited: string; | ||
onClick: () => void; | ||
}; | ||
|
||
const formatDate = (dateString: string) => { | ||
const date = new Date(dateString); | ||
const now = new Date(); | ||
const rtf = new Intl.RelativeTimeFormat('ko', { numeric: 'auto' }); | ||
const diffMinutes = Math.floor((date.getTime() - now.getTime()) / (1000 * 60)); | ||
const diffHours = Math.floor(diffMinutes / 60); | ||
if (diffMinutes > -60) { | ||
return rtf.format(diffMinutes, 'minute'); | ||
} | ||
|
||
if (diffHours > -24) { | ||
return rtf.format(diffHours, 'hour'); | ||
} | ||
return new Intl.DateTimeFormat('ko', { | ||
year: 'numeric', | ||
month: '2-digit', | ||
day: '2-digit', | ||
}).format(date); | ||
}; | ||
|
||
export const WorkspaceItem = ({ title, thumbnail, lastEdited }: WorkspaceItemProps) => { | ||
export const WorkspaceItem = ({ title, thumbnail, lastEdited, onClick }: WorkspaceItemProps) => { | ||
const { openModal: onOpen } = useModalStore(); | ||
return ( | ||
<li className="shadow-drop relative rounded-lg"> | ||
<button className="absolute right-2 top-2 text-gray-300 hover:text-red-500" onClick={onOpen}> | ||
<TrashSVG width={16} /> | ||
</button> | ||
<div className="flex h-[180px] overflow-hidden bg-gray-50"> | ||
{/* TODO: 썸네일 형태에 따라 이미지 태그 OR 백그라운드로 지정 */} | ||
{thumbnail && ( | ||
<img src={thumbnail} alt="workspace thumbnail" className="h-32 w-full object-cover" /> | ||
)} | ||
<div className="cursor-pointer" onClick={onClick}> | ||
<div className="flex h-[180px] overflow-hidden bg-gray-50"> | ||
{/* TODO: 썸네일 형태에 따라 이미지 태그 OR 백그라운드로 지정 */} | ||
{thumbnail && ( | ||
<img src={thumbnail} alt="workspace thumbnail" className="h-32 w-full object-cover" /> | ||
)} | ||
</div> | ||
<aside className="p-4 pb-6"> | ||
<h4 className="text-bold-md mb-1.5 text-gray-500">{title}</h4> | ||
<p className="text-medium-sm text-gray-200">{formatRelativeOrAbsoluteDate(lastEdited)}</p> | ||
</aside> | ||
</div> | ||
|
||
<aside className="p-4 pb-6"> | ||
<h4 className="text-bold-md mb-1.5 text-gray-500">{title}</h4> | ||
<p className="text-medium-sm text-gray-200">{formatDate(lastEdited)}</p> | ||
</aside> | ||
</li> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const WorkspaceLoadError = () => { | ||
return ( | ||
<div className="flex h-[23rem] w-full flex-col items-center justify-center gap-4 rounded-lg bg-gray-50 text-gray-200"> | ||
<img src="./images/not_found.png" className="h-40 w-40" /> | ||
<p className="text-center">워크스페이스를 불러오지 못했습니다.</p> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { useCreateWorkspace } from './queries/useCreateWorkspace'; | ||
export { useGetWorkspaceList } from './queries/useGetWorkspaceList'; | ||
export { useGetWorkspace } from './queries/useGetWorkspace'; | ||
export { useUpdateWorkspaceName } from './queries/useUpdateWorkspaceName'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { WorkspaceApi } from '@/shared/api'; | ||
import { getUserId } from '@/shared/utils'; | ||
import toast from 'react-hot-toast'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useWorkspaceStore } from '@/shared/store'; | ||
|
||
export const useGetWorkspace = (workspaceId: string) => { | ||
const workspaceApi = WorkspaceApi(); | ||
const userId = getUserId(); | ||
const { setName } = useWorkspaceStore(); | ||
const { data, isPending, isError } = useQuery({ | ||
queryKey: ['getWorkspace', workspaceId], | ||
queryFn: () => { | ||
return workspaceApi.getWorkspace(userId, workspaceId); | ||
}, | ||
}); | ||
|
||
React.useEffect(() => { | ||
if (isError) { | ||
toast.error('워크스페이스 정보 불러오기 실패'); | ||
return; | ||
} | ||
if (data) { | ||
setName(data.workspaceDto.name); | ||
} | ||
}, [data, setName, isError]); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 감사합니다 |
||
return { data, isPending, isError }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
apps/client/src/shared/hooks/queries/useUpdateWorkspaceName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { WorkspaceApi } from '@/shared/api'; | ||
import { getUserId } from '@/shared/utils'; | ||
import toast from 'react-hot-toast'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { useWorkspaceStore } from '@/shared/store'; | ||
|
||
export const useUpdateWorkspaceName = () => { | ||
const workspaceApi = WorkspaceApi(); | ||
const userId = getUserId(); | ||
const { setName } = useWorkspaceStore(); | ||
|
||
const { mutate, isPending } = useMutation({ | ||
mutationFn: ({ workspaceId, newName }: { workspaceId: string; newName: string }) => { | ||
return workspaceApi.updateWorkspaceName(userId, workspaceId, newName); | ||
}, | ||
onSuccess: (data) => { | ||
toast.success('워크스페이스 이름이 변경되었습니다.'); | ||
setName(data?.name!); | ||
}, | ||
onError: () => { | ||
toast.error('워크스페이스 이름 변경을 실패했습니다.'); | ||
}, | ||
}); | ||
|
||
return { mutate, isPending }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { useLoadingStore } from './useLoadingStore'; | ||
export { useModalStore } from './useModalStore'; | ||
export { useWorkspaceStore } from './useWorkspaceStore'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { create } from 'zustand'; | ||
|
||
type TWorkspace = { | ||
name: string; | ||
setName: (newName: string) => void; | ||
}; | ||
|
||
export const useWorkspaceStore = create<TWorkspace>((set) => ({ | ||
name: '워크스페이스 이름', | ||
setName: (newName) => set({ name: newName }), | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
성공/실패시 문구를 통일하면 어떨까 싶습니다