-
Notifications
You must be signed in to change notification settings - Fork 2
feat(repo): GitHub 레포지토리 후보 조회 및 등록 기능 실제 API 연동 #25
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
Merged
i3months
merged 10 commits into
feature/resume-management
from
feature/github-management
May 20, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fc89f4a
docs(features): repo feature status 문서 업데이트
Jaeho-Site 75cac02
feat(repo): Repository 타입 정의 추가
Jaeho-Site acd5374
feat(repo): repo API client 함수 구현
Jaeho-Site dc6ea24
feat(repo): useRepos 훅 구현
Jaeho-Site af87035
feat(repo): CandidateRepositoryList 컴포넌트 추가
Jaeho-Site 46d5fa7
feat(repo): RegisteredRepositoryList 컴포넌트 추가
Jaeho-Site 64e8ac9
feat(repo): RepositoryPanel 컴포넌트 추가
Jaeho-Site 452e24b
feat(repo): repo 기능 인덱스 파일 추가
Jaeho-Site 3ed5ed7
feat(workspace): RepositoryPanel 컴포넌트로 레포지토리 섹션 구현
Jaeho-Site 95c247e
fix(repo): private 레포 접근 불가 수정
Jaeho-Site 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 hidden or 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 hidden or 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,48 @@ | ||
| import { apiClient } from '@/shared/api' | ||
| import type { | ||
| CandidateRepositoryPageResponse, | ||
| PageResponse, | ||
| RegisteredRepositoryResponse, | ||
| } from '@/features/repo/model/types' | ||
|
|
||
| export async function listCandidates( | ||
| page = 1, | ||
| perPage = 30, | ||
| ): Promise<CandidateRepositoryPageResponse> { | ||
| const { data } = await apiClient.get<CandidateRepositoryPageResponse>( | ||
| '/api/repositories/github', { params: { page, perPage } }, | ||
| ) | ||
| return data | ||
| } | ||
|
|
||
| export async function registerRepo( | ||
| githubRepoId: number, | ||
| ): Promise<RegisteredRepositoryResponse> { | ||
| const { data } = await apiClient.post<RegisteredRepositoryResponse>( | ||
| '/api/repositories', { githubRepoId }, | ||
| ) | ||
| return data | ||
| } | ||
|
|
||
| export async function listRegistered( | ||
| page = 0, | ||
| size = 20, | ||
| ): Promise<PageResponse<RegisteredRepositoryResponse>> { | ||
| const { data } = await apiClient.get<PageResponse<RegisteredRepositoryResponse>>( | ||
| '/api/repositories', { params: { page, size, sort: 'createdAt,desc' } }, | ||
| ) | ||
| return data | ||
| } | ||
|
|
||
| export async function getRepo( | ||
| id: number, | ||
| ): Promise<RegisteredRepositoryResponse> { | ||
| const { data } = await apiClient.get<RegisteredRepositoryResponse>( | ||
| `/api/repositories/${id}`, | ||
| ) | ||
| return data | ||
| } | ||
|
|
||
| export async function deleteRepo(id: number): Promise<void> { | ||
| await apiClient.delete(`/api/repositories/${id}`) | ||
| } |
This file contains hidden or 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 { RepositoryPanel } from './ui/RepositoryPanel' | ||
| export type { | ||
| CandidateRepositoryPageResponse, | ||
| CandidateRepositoryResponse, | ||
| PageResponse, | ||
| RegisteredRepositoryResponse, | ||
| RepositoryStatus, | ||
| } from './model/types' |
This file contains hidden or 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,46 @@ | ||
| //중복되는 타입일 수 있으나 정의하는 상태가 달라서 일단 분리 X | ||
|
Member
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. 확인했습니다. |
||
| export type RepositoryStatus = | ||
| | 'PENDING' | ||
| | 'ANALYZING' | ||
| | 'ANALYZED' | ||
| | 'FAILED' | ||
|
|
||
| export type CandidateRepositoryResponse = { | ||
| githubRepoId: number | ||
| name: string | ||
| fullName: string | ||
| htmlUrl: string | ||
| defaultBranch: string | ||
| private: boolean | ||
| description: string | null | ||
| alreadyRegistered: boolean | ||
| } | ||
|
|
||
| export type CandidateRepositoryPageResponse = { | ||
| content: CandidateRepositoryResponse[] | ||
| page: number | ||
| perPage: number | ||
| hasNext: boolean | ||
| } | ||
|
|
||
| export type RegisteredRepositoryResponse = { | ||
| id: number | ||
| githubRepoId: number | ||
| repoName: string | ||
| repoFullName: string | ||
| repoUrl: string | ||
| defaultBranch: string | ||
| status: RepositoryStatus | ||
| lastSyncedAt: string | null | ||
| createdAt: string | ||
| } | ||
|
|
||
| export type PageResponse<T> = { | ||
| content: T[] | ||
| page: number | ||
| size: number | ||
| totalElements: number | ||
| totalPages: number | ||
| first: boolean | ||
| last: boolean | ||
| } | ||
This file contains hidden or 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,77 @@ | ||
| import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' | ||
| import { | ||
| deleteRepo, | ||
| getRepo, | ||
| listCandidates, | ||
| listRegistered, | ||
| registerRepo, | ||
| } from '@/features/repo/api/repo' | ||
| import type { | ||
| PageResponse, | ||
| RegisteredRepositoryResponse, | ||
| } from '@/features/repo/model/types' | ||
|
|
||
| const REGISTERED_KEY = 'repositories' as const | ||
| const CANDIDATES_KEY = 'repositories-candidates' as const | ||
| const POLL_INTERVAL_MS = 2_000 | ||
|
|
||
| function hasInProgress( | ||
| page: PageResponse<RegisteredRepositoryResponse> | undefined, | ||
| ): boolean { | ||
| if (!page) return false | ||
| return page.content.some( | ||
| (r) => r.status === 'PENDING' || r.status === 'ANALYZING', | ||
| ) | ||
| } | ||
|
|
||
| export function useRegisteredReposQuery(page = 0, size = 20) { | ||
| return useQuery({ | ||
| queryKey: [REGISTERED_KEY, page, size], | ||
| queryFn: () => listRegistered(page, size), | ||
| refetchInterval: (query) => | ||
| hasInProgress(query.state.data) ? POLL_INTERVAL_MS : false, | ||
| }) | ||
| } | ||
|
|
||
| export function useRegisteredRepoQuery(id: number | null) { | ||
| return useQuery({ | ||
| queryKey: [REGISTERED_KEY, 'detail', id], | ||
| queryFn: () => getRepo(id as number), | ||
| enabled: id !== null, | ||
| refetchInterval: (query) => { | ||
| const status = query.state.data?.status | ||
| return status === 'PENDING' || status === 'ANALYZING' | ||
| ? POLL_INTERVAL_MS | ||
| : false | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| export function useCandidateReposQuery(page = 1, perPage = 30) { | ||
| return useQuery({ | ||
| queryKey: [CANDIDATES_KEY, page, perPage], | ||
| queryFn: () => listCandidates(page, perPage), | ||
| }) | ||
| } | ||
|
|
||
| export function useRegisterRepoMutation() { | ||
| const qc = useQueryClient() | ||
| return useMutation({ | ||
| mutationFn: (githubRepoId: number) => registerRepo(githubRepoId), | ||
| onSuccess: () => { | ||
| qc.invalidateQueries({ queryKey: [REGISTERED_KEY] }) | ||
| qc.invalidateQueries({ queryKey: [CANDIDATES_KEY] }) | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| export function useDeleteRepoMutation() { | ||
| const qc = useQueryClient() | ||
| return useMutation({ | ||
| mutationFn: (id: number) => deleteRepo(id), | ||
| onSuccess: () => { | ||
| qc.invalidateQueries({ queryKey: [REGISTERED_KEY] }) | ||
| qc.invalidateQueries({ queryKey: [CANDIDATES_KEY] }) | ||
| }, | ||
| }) | ||
| } |
155 changes: 155 additions & 0 deletions
155
frontend/src/features/repo/ui/CandidateRepositoryList.tsx
This file contains hidden or 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,155 @@ | ||
| import { useState } from 'react' | ||
| import { isApiError } from '@/shared/api' | ||
| import { | ||
| useCandidateReposQuery, | ||
| useRegisterRepoMutation, | ||
| } from '@/features/repo/model/useRepos' | ||
| import type { CandidateRepositoryResponse } from '@/features/repo/model/types' | ||
|
|
||
| export function CandidateRepositoryList() { | ||
| const { data, isLoading, isError, error, refetch } = useCandidateReposQuery() | ||
| const [errorMessage, setErrorMessage] = useState<string | null>(null) | ||
|
|
||
| if (isLoading) return <ListSkeleton /> | ||
| if (isError) { | ||
| const message = isApiError(error) | ||
| ? error.message | ||
| : 'GitHub 레포 후보를 불러오지 못했습니다.' | ||
| return ( | ||
| <div className="rounded-xl border border-border bg-surface-raised p-8 text-center"> | ||
| <p role="alert" className="text-body text-danger-700"> | ||
| {message} | ||
| </p> | ||
| <button | ||
| type="button" | ||
| onClick={() => refetch()} | ||
| className="mt-4 inline-flex items-center px-4 py-2 rounded-pill bg-sage-900 text-white text-button hover:bg-sage-800 transition-colors duration-fast" | ||
| > | ||
| 다시 시도 | ||
| </button> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| const candidates = data?.content ?? [] | ||
| if (candidates.length === 0) { | ||
| return ( | ||
| <div className="rounded-xl border border-dashed border-border-strong bg-surface p-10 text-center"> | ||
| <p className="text-body text-fg-muted"> | ||
| 가져올 수 있는 GitHub 레포가 없습니다. | ||
| </p> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <div className="space-y-3"> | ||
| {errorMessage ? ( | ||
| <p role="alert" className="text-caption text-danger-700"> | ||
| {errorMessage} | ||
| </p> | ||
| ) : null} | ||
| <ul className="grid gap-3"> | ||
| {candidates.map((candidate) => ( | ||
| <li key={candidate.githubRepoId}> | ||
| <CandidateCard | ||
| candidate={candidate} | ||
| onError={setErrorMessage} | ||
| onClearError={() => setErrorMessage(null)} | ||
| /> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| function CandidateCard({ | ||
| candidate, | ||
| onError, | ||
| onClearError, | ||
| }: { | ||
| candidate: CandidateRepositoryResponse | ||
| onError: (message: string) => void | ||
| onClearError: () => void | ||
| }) { | ||
| const register = useRegisterRepoMutation() | ||
| const disabled = candidate.alreadyRegistered || register.isPending | ||
|
|
||
| const handleClick = () => { | ||
| onClearError() | ||
| register.mutate(candidate.githubRepoId, { | ||
| onError: (err) => { | ||
| onError( | ||
| isApiError(err) ? err.message : '등록 중 오류가 발생했습니다.', | ||
| ) | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| return ( | ||
| <article className="rounded-xl bg-surface-raised border border-border shadow-sm p-5 flex items-start gap-4"> | ||
| <div className="min-w-0 flex-1"> | ||
| <div className="flex items-center gap-2 flex-wrap"> | ||
| <a | ||
| href={candidate.htmlUrl} | ||
| target="_blank" | ||
| rel="noreferrer noopener" | ||
| className="text-body text-fg-strong font-semibold hover:underline truncate" | ||
| > | ||
| {candidate.fullName} | ||
| </a> | ||
| {candidate.private ? ( | ||
| <span className="inline-flex items-center px-2 py-0.5 rounded-pill text-caption font-mono bg-warning-50 text-warning-700"> | ||
| Private | ||
| </span> | ||
| ) : null} | ||
| {candidate.alreadyRegistered ? ( | ||
| <span className="inline-flex items-center px-2 py-0.5 rounded-pill text-caption font-mono bg-success-50 text-success-700"> | ||
| 이미 등록됨 | ||
| </span> | ||
| ) : null} | ||
| </div> | ||
| <p className="text-caption text-fg-muted mt-1.5 line-clamp-2"> | ||
| {candidate.description ?? '설명 없음'} | ||
| </p> | ||
| <p className="text-caption text-fg-subtle mt-1 font-mono"> | ||
| 기본 브랜치 {candidate.defaultBranch} | ||
| </p> | ||
| </div> | ||
| <button | ||
| type="button" | ||
| onClick={handleClick} | ||
| disabled={disabled} | ||
| aria-busy={register.isPending} | ||
| className="shrink-0 inline-flex items-center px-4 py-2 rounded-pill bg-sage-900 text-white text-button hover:bg-sage-800 transition-colors duration-fast disabled:opacity-60 disabled:cursor-not-allowed" | ||
| > | ||
| {register.isPending | ||
| ? '등록 중…' | ||
| : candidate.alreadyRegistered | ||
| ? '등록됨' | ||
| : '등록'} | ||
| </button> | ||
| </article> | ||
| ) | ||
| } | ||
|
|
||
| function ListSkeleton() { | ||
| return ( | ||
| <ul | ||
| aria-busy="true" | ||
| aria-label="GitHub 후보 로딩 중" | ||
| className="grid gap-3" | ||
| > | ||
| {[0, 1, 2, 3].map((i) => ( | ||
| <li | ||
| key={i} | ||
| className="rounded-xl bg-surface-raised border border-border shadow-sm p-5" | ||
| > | ||
| <div className="h-4 w-1/2 rounded bg-sage-100 animate-pulse" /> | ||
| <div className="mt-2 h-3 w-3/4 rounded bg-sage-100 animate-pulse" /> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| ) | ||
| } |
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.
굿~