Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions src/shared/api/msw/handlers/authHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { http, HttpResponse } from 'msw'

import { mockAccessToken, mockUser } from '@/shared/api/mock/mockUser'
import {
mockAccessToken,
mockUser,
mockUserChannelDetails,
} from '@/shared/api/mock/mockUser'
import { isMockChannelConnected } from './channelConnectHandlers'

// ์„œ๋น„์Šค ์›Œ์ปค ์ปจํ…์ŠคํŠธ์—์„œ mock ๋กœ๊ทธ์ธ ์ƒํƒœ๋ฅผ ์ถ”์ ํ•˜๋Š” ํ”Œ๋ž˜๊ทธ
// httpOnly ์ฟ ํ‚ค๋Š” ์„œ๋น„์Šค ์›Œ์ปค์—์„œ ์ฝ์„ ์ˆ˜ ์—†์œผ๋ฏ€๋กœ ๋ชจ๋“ˆ ๋ณ€์ˆ˜๋กœ ๊ด€๋ฆฌ
Expand All @@ -15,7 +20,12 @@ export const authHandlers = [

return HttpResponse.json({
success: true,
responseDto: mockUser,
responseDto: {
...mockUser,
userChannelDetails: isMockChannelConnected()
? mockUserChannelDetails
: null,
},
error: null,
})
}),
Expand Down
22 changes: 22 additions & 0 deletions src/shared/api/msw/handlers/channelConnectHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { http, HttpResponse } from 'msw'

const STORAGE_KEY = 'mock:channelConnected'

// mock ์—ฐ๋™ ์ƒํƒœ๋Š” ์ƒˆ๋กœ๊ณ ์นจ ์‹œ ๋ชจ๋“ˆ ๋ณ€์ˆ˜๊ฐ€ ์ดˆ๊ธฐํ™”๋˜๋ฏ€๋กœ localStorage๋กœ ์œ ์ง€
// (node ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ ๋“ฑ localStorage๊ฐ€ ์—†์œผ๋ฉด ํ•ญ์ƒ ๋ฏธ์—ฐ๋™์œผ๋กœ ๋™์ž‘)
export function isMockChannelConnected() {
return (
typeof localStorage !== 'undefined' &&
localStorage.getItem(STORAGE_KEY) === 'true'
)
}

function setMockChannelConnected(connected: boolean) {
if (typeof localStorage === 'undefined') return
if (connected) {
localStorage.setItem(STORAGE_KEY, 'true')
} else {
localStorage.removeItem(STORAGE_KEY)
}
}

const mockChannelConnectResponse = {
success: true,
responseDto: {
Expand All @@ -14,6 +34,7 @@ export const channelConnectHandlers = [
http.post(
`${process.env.NEXT_PUBLIC_API_URL}/channels/connect`,
async () => {
setMockChannelConnected(true)
return HttpResponse.json(mockChannelConnectResponse)
}
),
Expand All @@ -28,6 +49,7 @@ export const channelConnectHandlers = [
http.delete(
`${process.env.NEXT_PUBLIC_API_URL}/channels/connect/:channelId`,
async () => {
setMockChannelConnected(false)
return HttpResponse.json({ success: true, responseDto: null, error: null })
}
),
Expand Down
2 changes: 1 addition & 1 deletion src/shared/ui/toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Toggle({ label, pressed, onClick, className, children }: ToggleProps) {
'text-noto-label-sm-thin whitespace-nowrap text-text-and-icon-secondary',

/* ์ƒ‰์ƒ */
'border border-stroke-border-gray-default bg-transparent',
'border border-stroke-border-gray-default bg-white',

/* ๊ธฐ๋ณธ ์ƒํƒœ */
'cursor-pointer transition-all outline-none select-none',
Expand Down