78 lines
2.6 KiB
TypeScript
78 lines
2.6 KiB
TypeScript
import type {
|
|
WebInspectionData,
|
|
ReqGetInspectionData,
|
|
ResGetInspectionData,
|
|
} from '#layers/types/InspectionType'
|
|
|
|
/**
|
|
* 웹 점검
|
|
*/
|
|
export const useGetInspectionDataExternal = () => {
|
|
const inspectionStore = useInspectionStore()
|
|
const logPrefix = {
|
|
exception: '[Exception] /composables/useGetInspectionDataExternal',
|
|
failure: '[Failure] /composables/useGetInspectionDataExternal',
|
|
}
|
|
const webInspectionData = ref<WebInspectionData | null>(null)
|
|
const isWebInspection = ref(false) // 웹 점검 여부
|
|
|
|
// [Setter] 웹 점검 여부 세팅
|
|
const setIsWebInspection = (status: boolean) => {
|
|
isWebInspection.value = status
|
|
}
|
|
|
|
/**
|
|
* 웹 점검 여부
|
|
*
|
|
* @param {ReqGetInspectionData} req
|
|
* @description https://wiki.smilegate.net/pages/viewpage.action?pageId=563198067
|
|
*/
|
|
const getInspectionDataExternal = async (req: ReqGetInspectionData) => {
|
|
// const runtimeConfig = useRuntimeConfig()
|
|
const apiUrl = `${req.baseApiUrl}/pub-comm/v3.0/inspection/${req.gameId}`
|
|
|
|
try {
|
|
const response = (await commonFetch(
|
|
'GET',
|
|
apiUrl
|
|
)) as ResGetInspectionData
|
|
console.log('🚀 ~ getInspectionDataExternal ~ response:', response)
|
|
|
|
// 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 && response.value.inspection) {
|
|
webInspectionData.value = response.value.inspection
|
|
isWebInspection.value = response.value.inspection_status === 1
|
|
|
|
inspectionStore.setWebInspectionData(webInspectionData.value)
|
|
inspectionStore.setWebInspectionStatus(isWebInspection.value)
|
|
}
|
|
} catch (e) {
|
|
console.error(`${logPrefix.exception}.getInspectionDataExternal: `, e)
|
|
}
|
|
|
|
if (webInspectionData.value !== null) {
|
|
setIsWebInspection(isWebInspection.value)
|
|
}
|
|
}
|
|
|
|
return { webInspectionData, isWebInspection, getInspectionDataExternal }
|
|
}
|