import {useVoluntaryMajorGroupIdentifier} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryMajorGroupIdentifier";

export const useVoluntaryPageDataFormat = (prevData) => {
    if (typeof prevData.value.userSnapshot === 'string') {
        prevData.value.userSnapshot = JSON.parse(prevData.value.userSnapshot)
    }
    if (typeof prevData.value.detail === 'string') {
        const parsedData = JSON.parse(prevData.value.detail)
        parsedData.batch?.wishes?.forEach(useVoluntaryMajorGroupIdentifier)
        prevData.value.detail = parsedData
    }
    prevData.value = prevData.value || {}
    prevData.value.userSnapshot = prevData.value.userSnapshot || {}
    prevData.value.detail = prevData.value.detail || {}
}