refactor(directory) : reduce client/prospect forms to company name
Les formulaires d'ajout/édition client et prospect ne conservent que le champ
« Nom société ». Les coordonnées (email, téléphone) et les champs prospect
(société, statut, source, notes) sont retirés : ils seront gérés via Contact.
Le statut prospect prend son défaut New à la création ; DTO assouplis, payload
réduit à { name }.
This commit is contained in:
@@ -6,21 +6,11 @@
|
|||||||
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
||||||
<MalioInputText
|
<MalioInputText
|
||||||
v-model="form.name"
|
v-model="form.name"
|
||||||
label="Nom"
|
label="Nom société"
|
||||||
input-class="w-full"
|
input-class="w-full"
|
||||||
:error="touched.name && !form.name.trim() ? 'Le nom est requis' : ''"
|
:error="touched.name && !form.name.trim() ? 'Le nom est requis' : ''"
|
||||||
@blur="touched.name = true"
|
@blur="touched.name = true"
|
||||||
/>
|
/>
|
||||||
<MalioInputText
|
|
||||||
v-model="form.email"
|
|
||||||
label="Email"
|
|
||||||
input-class="w-full"
|
|
||||||
/>
|
|
||||||
<MalioInputText
|
|
||||||
v-model="form.phone"
|
|
||||||
label="Téléphone"
|
|
||||||
input-class="w-full"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="mt-6 flex justify-end">
|
<div class="mt-6 flex justify-end">
|
||||||
<MalioButton
|
<MalioButton
|
||||||
@@ -58,28 +48,16 @@ const isSubmitting = ref(false)
|
|||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
email: '',
|
|
||||||
phone: '',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const touched = reactive({
|
const touched = reactive({
|
||||||
name: false,
|
name: false,
|
||||||
email: false,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(() => props.modelValue, (open) => {
|
watch(() => props.modelValue, (open) => {
|
||||||
if (open) {
|
if (open) {
|
||||||
if (props.client) {
|
form.name = props.client?.name ?? ''
|
||||||
form.name = props.client.name ?? ''
|
|
||||||
form.email = props.client.email ?? ''
|
|
||||||
form.phone = props.client.phone ?? ''
|
|
||||||
} else {
|
|
||||||
form.name = ''
|
|
||||||
form.email = ''
|
|
||||||
form.phone = ''
|
|
||||||
}
|
|
||||||
touched.name = false
|
touched.name = false
|
||||||
touched.email = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -93,8 +71,6 @@ async function handleSubmit() {
|
|||||||
try {
|
try {
|
||||||
const payload: ClientWrite = {
|
const payload: ClientWrite = {
|
||||||
name: form.name.trim(),
|
name: form.name.trim(),
|
||||||
email: form.email.trim() || null,
|
|
||||||
phone: form.phone.trim() || null,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEditing.value && props.client) {
|
if (isEditing.value && props.client) {
|
||||||
|
|||||||
@@ -6,41 +6,11 @@
|
|||||||
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
||||||
<MalioInputText
|
<MalioInputText
|
||||||
v-model="form.name"
|
v-model="form.name"
|
||||||
:label="$t('prospects.fields.name')"
|
label="Nom société"
|
||||||
input-class="w-full"
|
input-class="w-full"
|
||||||
:error="touched.name && !form.name.trim() ? $t('prospects.validation.nameRequired') : ''"
|
:error="touched.name && !form.name.trim() ? $t('prospects.validation.nameRequired') : ''"
|
||||||
@blur="touched.name = true"
|
@blur="touched.name = true"
|
||||||
/>
|
/>
|
||||||
<MalioInputText
|
|
||||||
v-model="form.company"
|
|
||||||
:label="$t('prospects.fields.company')"
|
|
||||||
input-class="w-full"
|
|
||||||
/>
|
|
||||||
<MalioInputText
|
|
||||||
v-model="form.email"
|
|
||||||
:label="$t('prospects.fields.email')"
|
|
||||||
input-class="w-full"
|
|
||||||
/>
|
|
||||||
<MalioInputText
|
|
||||||
v-model="form.phone"
|
|
||||||
:label="$t('prospects.fields.phone')"
|
|
||||||
input-class="w-full"
|
|
||||||
/>
|
|
||||||
<MalioSelect
|
|
||||||
v-model="form.status"
|
|
||||||
:label="$t('prospects.fields.status')"
|
|
||||||
:options="statusOptions"
|
|
||||||
group-class="w-full"
|
|
||||||
/>
|
|
||||||
<MalioInputText
|
|
||||||
v-model="form.source"
|
|
||||||
:label="$t('prospects.fields.source')"
|
|
||||||
input-class="w-full"
|
|
||||||
/>
|
|
||||||
<MalioInputTextArea
|
|
||||||
v-model="form.notes"
|
|
||||||
:label="$t('prospects.fields.notes')"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="mt-6 flex items-center justify-between gap-2">
|
<div class="mt-6 flex items-center justify-between gap-2">
|
||||||
<MalioButton
|
<MalioButton
|
||||||
@@ -69,7 +39,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Prospect, ProspectStatus, ProspectWrite } from '~/modules/directory/services/dto/prospect'
|
import type { Prospect, ProspectWrite } from '~/modules/directory/services/dto/prospect'
|
||||||
import { useProspectService } from '~/modules/directory/services/prospects'
|
import { useProspectService } from '~/modules/directory/services/prospects'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -82,8 +52,6 @@ const emit = defineEmits<{
|
|||||||
(e: 'saved'): void
|
(e: 'saved'): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const isOpen = computed({
|
const isOpen = computed({
|
||||||
get: () => props.modelValue,
|
get: () => props.modelValue,
|
||||||
set: (v) => emit('update:modelValue', v),
|
set: (v) => emit('update:modelValue', v),
|
||||||
@@ -93,30 +61,8 @@ const isEditing = computed(() => !!props.prospect)
|
|||||||
const isConverted = computed(() => !!props.prospect?.convertedClient)
|
const isConverted = computed(() => !!props.prospect?.convertedClient)
|
||||||
const isSubmitting = ref(false)
|
const isSubmitting = ref(false)
|
||||||
|
|
||||||
const statusOptions = [
|
const form = reactive({
|
||||||
{ label: t('prospects.status.new'), value: 'new' },
|
|
||||||
{ label: t('prospects.status.contacted'), value: 'contacted' },
|
|
||||||
{ label: t('prospects.status.qualified'), value: 'qualified' },
|
|
||||||
{ label: t('prospects.status.won'), value: 'won' },
|
|
||||||
{ label: t('prospects.status.lost'), value: 'lost' },
|
|
||||||
]
|
|
||||||
|
|
||||||
const form = reactive<{
|
|
||||||
name: string
|
|
||||||
company: string
|
|
||||||
email: string
|
|
||||||
phone: string
|
|
||||||
status: ProspectStatus
|
|
||||||
source: string
|
|
||||||
notes: string
|
|
||||||
}>({
|
|
||||||
name: '',
|
name: '',
|
||||||
company: '',
|
|
||||||
email: '',
|
|
||||||
phone: '',
|
|
||||||
status: 'new',
|
|
||||||
source: '',
|
|
||||||
notes: '',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const touched = reactive({
|
const touched = reactive({
|
||||||
@@ -125,23 +71,7 @@ const touched = reactive({
|
|||||||
|
|
||||||
watch(() => props.modelValue, (open) => {
|
watch(() => props.modelValue, (open) => {
|
||||||
if (open) {
|
if (open) {
|
||||||
if (props.prospect) {
|
form.name = props.prospect?.name ?? ''
|
||||||
form.name = props.prospect.name ?? ''
|
|
||||||
form.company = props.prospect.company ?? ''
|
|
||||||
form.email = props.prospect.email ?? ''
|
|
||||||
form.phone = props.prospect.phone ?? ''
|
|
||||||
form.status = props.prospect.status ?? 'new'
|
|
||||||
form.source = props.prospect.source ?? ''
|
|
||||||
form.notes = props.prospect.notes ?? ''
|
|
||||||
} else {
|
|
||||||
form.name = ''
|
|
||||||
form.company = ''
|
|
||||||
form.email = ''
|
|
||||||
form.phone = ''
|
|
||||||
form.status = 'new'
|
|
||||||
form.source = ''
|
|
||||||
form.notes = ''
|
|
||||||
}
|
|
||||||
touched.name = false
|
touched.name = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -156,12 +86,6 @@ async function handleSubmit() {
|
|||||||
try {
|
try {
|
||||||
const payload: ProspectWrite = {
|
const payload: ProspectWrite = {
|
||||||
name: form.name.trim(),
|
name: form.name.trim(),
|
||||||
company: form.company.trim() || null,
|
|
||||||
email: form.email.trim() || null,
|
|
||||||
phone: form.phone.trim() || null,
|
|
||||||
status: form.status,
|
|
||||||
source: form.source.trim() || null,
|
|
||||||
notes: form.notes.trim() || null,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEditing.value && props.prospect) {
|
if (isEditing.value && props.prospect) {
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ export type Client = {
|
|||||||
|
|
||||||
export type ClientWrite = {
|
export type ClientWrite = {
|
||||||
name: string
|
name: string
|
||||||
email: string | null
|
email?: string | null
|
||||||
phone: string | null
|
phone?: string | null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ export type Prospect = {
|
|||||||
|
|
||||||
export type ProspectWrite = {
|
export type ProspectWrite = {
|
||||||
name: string
|
name: string
|
||||||
company: string | null
|
company?: string | null
|
||||||
email: string | null
|
email?: string | null
|
||||||
phone: string | null
|
phone?: string | null
|
||||||
status: ProspectStatus
|
status?: ProspectStatus
|
||||||
source: string | null
|
source?: string | null
|
||||||
notes: string | null
|
notes?: string | null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user