<script setup lang="ts">
interface DialogPreviewData {
	projectName: string;
	onSave: (value: string) => void;
}

const props = defineProps<{
	data: DialogPreviewData;
	close: () => void;
}>();

const projectName = useXControl('');

onMounted(() => {
	projectName.setValue(props.data.projectName);
});

const save = (): void => {
	props.data.onSave(projectName.value);
	props.close();
};
</script>

<template>
	<div class="size-full flex flex-col divide-y">
		<div class="flex-1 px-4 py-6">
			<Input :control="projectName" label="dialogPreview.projectName" />
		</div>
		<div class="grid grid-cols-2 gap-2 p-4">
			<Button color="secondary" label="dialogPreview.cancel" @click="close" />
			<Button label="dialogPreview.save" @click="save" />
		</div>
	</div>
</template>
