import { computed, type ComputedRef } from "vue"; import type { AnyHistory } from "@/api"; import { useHistoryStore } from "@/stores/historyStore"; import { getHistoryUploadBlockReason, getHistoryUploadWarningMessage, type HistoryUploadBlockReason, } from "@/utils/historyUpload"; interface TargetHistoryUploadState { targetHistory: ComputedRef; uploadBlockReason: ComputedRef; warningMessage: ComputedRef; } export function useTargetHistoryUploadState( targetHistoryId: ComputedRef, ): TargetHistoryUploadState { const historyStore = useHistoryStore(); const targetHistory = computed(() => { const historyId = targetHistoryId.value; return historyId ? historyStore.getHistoryById(historyId, false) : null; }); const uploadBlockReason = computed(() => getHistoryUploadBlockReason(targetHistory.value)); const warningMessage = computed(() => getHistoryUploadWarningMessage(uploadBlockReason.value)); return { targetHistory, uploadBlockReason, warningMessage, }; }