-
Notifications
You must be signed in to change notification settings - Fork 2
[REFACTOR] 템플릿 데이터를 API에서 패칭하도록 수정 #426
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
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
57d3c09
refactor: API 기반 코드 준비
i-meant-to-be cb0ec16
refactor: UI가 데이터를 API에서 패칭하도록 수정
i-meant-to-be d58a84a
chore: 이제 사용하지 않는 상수 삭제
i-meant-to-be 829579d
chore: 다국어 번역 테이블에 항목 추가
i-meant-to-be d1e7b6e
Merge branch 'develop' into refactor/#425
i-meant-to-be 69f6583
fix: 병합 과정에서 누락된 프리뷰 관련 코드 추가
i-meant-to-be db05b23
fix: 코드 리뷰 반영
i-meant-to-be b606b6c
feat: 패치 노트가 랜딩 페이지와 시간표 목록 페이지에만 표시되도록 수정
i-meant-to-be 0a69b16
Revert "feat: 패치 노트가 랜딩 페이지와 시간표 목록 페이지에만 표시되도록 수정"
i-meant-to-be 90e727d
chore: 더 이상 필요하지 않은 에셋 삭제
i-meant-to-be 86b8065
test: msw가 정적 이미지 에셋 요청도 가로채도록 개선
i-meant-to-be 17b9460
refactor: 시간표 공유 관련 함수 한 파일로 통합 및 이름 변경
i-meant-to-be 80a4f6f
refactor: 조금 더 탄탄한 파싱 방식 적용
i-meant-to-be 53214bb
test: 테스트 함수 추가
i-meant-to-be 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
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,16 @@ | ||
| import { ApiUrl } from '../endpoints'; | ||
| import { request } from '../primitives'; | ||
| import { GetOrganizationTemplatesResponseType } from '../responses/organization'; | ||
|
|
||
| // GET /api/organizations/templates | ||
| export async function getOrganizationTemplates(): Promise<GetOrganizationTemplatesResponseType> { | ||
| const requestUrl: string = ApiUrl.organization + '/templates'; | ||
| const response = await request<GetOrganizationTemplatesResponseType>( | ||
| 'GET', | ||
| requestUrl, | ||
| null, | ||
| null, | ||
| ); | ||
|
|
||
| return response.data; | ||
| } |
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,5 @@ | ||
| import { Organization } from '../../type/type'; | ||
|
|
||
| export interface GetOrganizationTemplatesResponseType { | ||
| organizations: Organization[]; | ||
| } |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { GetOrganizationTemplatesResponseType } from '../../apis/responses/organization'; | ||
| import { getOrganizationTemplates } from '../../apis/apis/organization'; | ||
|
|
||
| export function useGetOrganizationTemplates(enabled?: boolean) { | ||
| return useQuery<GetOrganizationTemplatesResponseType>({ | ||
| queryKey: ['OrganizationTemplates'], | ||
| queryFn: () => getOrganizationTemplates(), | ||
| enabled, | ||
| throwOnError: false, | ||
| }); | ||
| } |
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
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,42 @@ | ||
| import { http, HttpResponse } from 'msw'; | ||
| import { ApiUrl } from '../../apis/endpoints'; | ||
|
|
||
| export const organizationHandlers = [ | ||
| // GET /api/organizations/templates | ||
| http.get(ApiUrl.organization + '/templates', () => { | ||
| return HttpResponse.json({ | ||
| organizations: [ | ||
| { | ||
| organization: '한앎', | ||
| affiliation: '한양대', | ||
| iconPath: '/icon/icon1.png', | ||
| templates: [ | ||
| { | ||
| name: '템플릿1', | ||
| data: 'eJyrVspMUbIytjDXUcrMS8tXsqpWykvMTVWyUjJWKCtWMFZ427b1TXPj27YFrxcueN3T8HZWj8LbGVPfdM9V0lEqqSwAqXQODQ7x9%2FWMcgUKJaan5qUkAgWB7IKi%2FOKQ1MRcP4iBbzasedOyESienJ%2BHLP56wwygwUDx8sSivMy8dKfUnBwlq7TEnOJUHaW0zLzM4gwkoVqgtYlJOUCN0dVKxSWJeckgMwKC%2FIOBJhQXpKYmZ4RAnPVmXivQzUDRpPwKqJCff5Cvow%2FI5Zkgqw2NDICyYLPzSnNyIMIBqUUgx6EJBRekJmYDHQcTLgbxU4sg3FodJKc4%2B%2FsNFqf4uYaGBIEtQXPNhDdzFkCiFMVNIZ6%2BrvFOjsGuLnB3QazA6TBzkLMx3AX2DIkhtHXOm0WtCq83zHkzbQfdAwpr8qG7i2JrAbdLRw0%3D', | ||
| }, | ||
| { | ||
| name: '템플릿2', | ||
| data: 'eJyrVspMUbIytjDXUcrMS8tXsqpWykvMTVWyUjJWKCtWMFZ427b1TXPj27YFrxcueN3T8HZWj8LbGVPfdM9V0lEqqSwAqXQODQ7x9%2FWMcgUKJaan5qUkAgWB7IKi%2FOKQ1MRcP4iBbzasedOyESienJ%2BHLP56wwygwUDx8sSivMy8dKfUnBwlq7TEnOJUHaW0zLzM4gwkoVqgtYlJOUCN0dVKxSWJeckgMwKC%2FIOBJhQXpKYmZ4RAnPVmXivQzUDRpPwKqJCff5Cvow%2FI5Zkgqw2NDICyYLPzSnNyIMIBqUUgx6EJBRekJmYDHQcTLgbxU4sg3FodJKc4%2B%2FsNFqf4uYaGBIEtQXPNhDdzFkCiFMVNIZ6%2BrvFOjsGuLnB3QazA6TBzkLMx3AX2DIkhtHXOm0WtCq83zHkzbQfdAwpr8qG7i2JrAbdLRw0%3D', | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| organization: '한모름', | ||
| affiliation: '양한대', | ||
| iconPath: '/icon/icon2.png', | ||
| templates: [ | ||
| { | ||
| name: '템플릿1', | ||
| data: 'eJyrVspMUbIytjDXUcrMS8tXsqpWykvMTVWyUjJWKCtWMFZ427b1TXPj27YFrxcueN3T8HZWj8LbGVPfdM9V0lEqqSwAqXQODQ7x9%2FWMcgUKJaan5qUkAgWB7IKi%2FOKQ1MRcP4iBbzasedOyESienJ%2BHLP56wwygwUDx8sSivMy8dKfUnBwlq7TEnOJUHaW0zLzM4gwkoVqgtYlJOUCN0dVKxSWJeckgMwKC%2FIOBJhQXpKYmZ4RAnPVmXivQzUDRpPwKqJCff5Cvow%2FI5Zkgqw2NDICyYLPzSnNyIMIBqUUgx6EJBRekJmYDHQcTLgbxU4sg3FodJKc4%2B%2FsNFqf4uYaGBIEtQXPNhDdzFkCiFMVNIZ6%2BrvFOjsGuLnB3QazA6TBzkLMx3AX2DIkhtHXOm0WtCq83zHkzbQfdAwpr8qG7i2JrAbdLRw0%3D', | ||
| }, | ||
| { | ||
| name: '템플릿2', | ||
| data: 'eJyrVspMUbIytjDXUcrMS8tXsqpWykvMTVWyUjJWKCtWMFZ427b1TXPj27YFrxcueN3T8HZWj8LbGVPfdM9V0lEqqSwAqXQODQ7x9%2FWMcgUKJaan5qUkAgWB7IKi%2FOKQ1MRcP4iBbzasedOyESienJ%2BHLP56wwygwUDx8sSivMy8dKfUnBwlq7TEnOJUHaW0zLzM4gwkoVqgtYlJOUCN0dVKxSWJeckgMwKC%2FIOBJhQXpKYmZ4RAnPVmXivQzUDRpPwKqJCff5Cvow%2FI5Zkgqw2NDICyYLPzSnNyIMIBqUUgx6EJBRekJmYDHQcTLgbxU4sg3FodJKc4%2B%2FsNFqf4uYaGBIEtQXPNhDdzFkCiFMVNIZ6%2BrvFOjsGuLnB3QazA6TBzkLMx3AX2DIkhtHXOm0WtCq83zHkzbQfdAwpr8qG7i2JrAbdLRw0%3D', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }); | ||
| }), | ||
| ]; |
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,31 @@ | ||
| import { http, HttpResponse } from 'msw'; | ||
| import sampleLogo from '../../assets/template_logo/government.png'; | ||
|
|
||
| const baseUrl = import.meta.env.VITE_API_BASE_URL || ''; | ||
|
|
||
| export const staticAssetHandlers = [ | ||
| http.get(baseUrl + '/icon/:iconFileName', async ({ params }) => { | ||
| const { iconFileName } = params; | ||
| console.log(`# Requested icon file's name = ${iconFileName}`); | ||
|
|
||
| const targetLocalImage = sampleLogo; | ||
|
|
||
| try { | ||
| // 로컬 이미지 에셋을 ArrayBuffer의 형태로 불러옴 | ||
| const imageResponse = await fetch(targetLocalImage); | ||
| const imageBuffer = await imageResponse.arrayBuffer(); | ||
| const contentType = 'image/png'; | ||
|
|
||
| // 실제 이미지 응답처럼 ArrayBuffer와 헤더를 반환 | ||
| return HttpResponse.arrayBuffer(imageBuffer, { | ||
| headers: { | ||
| 'Content-Type': contentType, | ||
| 'Cache-Control': 'max-age=31536000, immutable', // S3-like cache header | ||
| }, | ||
| }); | ||
| } catch (error) { | ||
| console.error('Failed to load mock image asset:', error); | ||
| return new HttpResponse(null, { status: 500 }); | ||
| } | ||
| }), | ||
| ]; | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.