// Thin compatibility wrapper: marital API now lives in the `taxstore`.
import { computed } from 'vue'
import { useTaxstore } from './taxstore'
import type { AddressOut } from 'src/components/AddressInput.vue'
import type { CommentAttachmentData } from 'src/components/CommentAttachment.vue'

export interface MaritalData {
	alimentiVersati: boolean
	alimentiCommenti: CommentAttachmentData
	maritalStatus: string
	spouseFirstName: string | number | null
	spouseLastName: string | number | null
	spouseBirthDate: string | number | FileList | null | undefined
	spouseDeadDate: string | number | FileList | null | undefined
	spouseTaxNumber: string
	spouseAddress: AddressOut
	marriageDate: string
	separated: boolean
	spouseAlimentiVersati: boolean
}

export const useMaritalStore = () => {
	const store = useTaxstore()

	const data = computed(() => store.getMarital())

	function set(partial: Partial<MaritalData>) {
		store.setMarital(partial)
	}

	function replace(payload: MaritalData) {
		store.replaceMarital(payload)
	}

	function reset() {
		store.resetMarital()
	}

	return { data, set, replace, reset }
}
