<script setup lang="ts">
import { Resume, ResumeComponentPlacement } from '@/types/resume';
import ResumeComponent from './ResumeComponent.vue';
import PrintResumeButton from './PrintResumeButton.vue';
import ResumeNameInput from './ResumeNameInput.vue';

const props = defineProps<{
    resume: Resume,
    selectedComponent: ResumeComponentPlacement | null
}>();

const emit = defineEmits(['selected-component-change', 'update:resume-title']);
</script>

<template>
    <div class="flex-2 flex flex-col gap-3 w-full">
        <div id="tools" class="w-full flex gap-3 justify-between">
            <ResumeNameInput :resume="props.resume" :resumeTitle="props.resume.name" @update:resume-title="emit('update:resume-title', $event)" />
            <PrintResumeButton :resume="props.resume" />
        </div>
        <div id="resume" class="aspect-[0.707317073] w-full max-w-[84.1cm] bg-white text-black">
            <ResumeComponent v-for="componentPlacement in props.resume.components_placements" :key="componentPlacement.id" :componentPlacement="componentPlacement" @click="emit('selected-component-change', componentPlacement)" />
        </div>
    </div>
</template>
