Files
web-temp/layers/composables/useGetGameDataExternal.ts
2025-11-11 18:50:14 +09:00

53 lines
1.8 KiB
TypeScript

import type {
GameDataResponse,
GameDataRequest,
} from '#layers/types/api/gameData'
export const useGetGameDataExternal = () => {
const { setGameData } = useGameDataStore()
const logPrefix = {
exception: '[Exception] /composables/useGetGameDataExternal',
failure: '[Failure] /composables/useGetGameDataExternal',
}
const webGameData = ref<GameDataResponse | null>(null)
const getGameDataExternal = async (req: GameDataRequest) => {
const runtimeConfig = useRuntimeConfig()
const stoveApiBaseUrl = runtimeConfig.public.stoveApiUrl
const apiUrl = `${stoveApiBaseUrl}/pub-comm/v1.0/template/game?game_domain=${req.gameDomain}&lang_code=${req.langCode}`
try {
const response = (await commonFetch('GET', apiUrl)) as GameDataResponse
console.log('🚀 ~ getGameDataExternal:', response.value)
// FIXME: 테스트용 데이터 ---------------------------------------------------
/* if (['local', 'local-gate8', 'dev'].includes(`${runtimeConfig.public.runType}`)) {
response.value = {
inspection_status: 1,
inspection: {
inspection_status: 1,
start_date: '2025-09-19 10:00:00',
end_date: '2025-09-19 12:00:00',
ts_start_date: new Date().getTime(),
ts_end_date: new Date().getTime(),
back_ground_image_type: 'image',
back_ground_image_url: 'https://www.onstove.com',
inspection_title1: '',
inspection_title2: ''
}
}
} */
// ------------------------------------------------------------------------
if (response?.value) {
webGameData.value = response
setGameData(response.value)
}
} catch (e) {
console.error(`${logPrefix.exception}.getGameDataExternal: `, e)
}
}
return { webGameData, getGameDataExternal }
}