feat: frontend fase 2 sessies 1-3
- Member management pagina + invite flow - Persons module met filters, KPI tiles, detail panel - Event horizontale tabs navigatie (EventTabsNav component) - Route conflict opgelost - OrganisationSwitcher verbeterd (collapsed staat WIP)
This commit is contained in:
205
apps/app/src/components/persons/EditPersonDialog.vue
Normal file
205
apps/app/src/components/persons/EditPersonDialog.vue
Normal file
@@ -0,0 +1,205 @@
|
||||
<script setup lang="ts">
|
||||
import { VForm } from 'vuetify/components/VForm'
|
||||
import { useUpdatePerson } from '@/composables/api/usePersons'
|
||||
import { useCrowdTypeList } from '@/composables/api/useCrowdTypes'
|
||||
import { requiredValidator, emailValidator } from '@core/utils/validators'
|
||||
import type { Person, PersonStatus } from '@/types/person'
|
||||
|
||||
const props = defineProps<{
|
||||
person: Person
|
||||
eventId: string
|
||||
orgId: string
|
||||
}>()
|
||||
|
||||
const modelValue = defineModel<boolean>({ required: true })
|
||||
|
||||
const eventIdRef = computed(() => props.eventId)
|
||||
const orgIdRef = computed(() => props.orgId)
|
||||
|
||||
const { data: crowdTypes } = useCrowdTypeList(orgIdRef)
|
||||
const { mutate: updatePerson, isPending } = useUpdatePerson(eventIdRef)
|
||||
|
||||
const form = ref({
|
||||
crowd_type_id: '',
|
||||
name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
status: 'pending' as PersonStatus,
|
||||
admin_notes: '',
|
||||
is_blacklisted: false,
|
||||
})
|
||||
|
||||
const errors = ref<Record<string, string>>({})
|
||||
const refVForm = ref<VForm>()
|
||||
const showSuccess = ref(false)
|
||||
|
||||
watch(() => props.person, (p) => {
|
||||
form.value = {
|
||||
crowd_type_id: p.crowd_type?.id ?? '',
|
||||
name: p.name,
|
||||
email: p.email,
|
||||
phone: p.phone ?? '',
|
||||
status: p.status,
|
||||
admin_notes: p.admin_notes ?? '',
|
||||
is_blacklisted: p.is_blacklisted,
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
const crowdTypeItems = computed(() =>
|
||||
crowdTypes.value?.map(ct => ({
|
||||
title: ct.name,
|
||||
value: ct.id,
|
||||
})) ?? [],
|
||||
)
|
||||
|
||||
const statusOptions: { title: string; value: PersonStatus }[] = [
|
||||
{ title: 'Pending', value: 'pending' },
|
||||
{ title: 'Uitgenodigd', value: 'invited' },
|
||||
{ title: 'Aangemeld', value: 'applied' },
|
||||
{ title: 'Goedgekeurd', value: 'approved' },
|
||||
{ title: 'Afgewezen', value: 'rejected' },
|
||||
{ title: 'No-show', value: 'no_show' },
|
||||
]
|
||||
|
||||
function onSubmit() {
|
||||
refVForm.value?.validate().then(({ valid }) => {
|
||||
if (!valid) return
|
||||
|
||||
errors.value = {}
|
||||
|
||||
updatePerson({
|
||||
id: props.person.id,
|
||||
crowd_type_id: form.value.crowd_type_id,
|
||||
name: form.value.name,
|
||||
email: form.value.email,
|
||||
phone: form.value.phone || undefined,
|
||||
status: form.value.status,
|
||||
admin_notes: form.value.admin_notes || undefined,
|
||||
is_blacklisted: form.value.is_blacklisted,
|
||||
}, {
|
||||
onSuccess: () => {
|
||||
modelValue.value = false
|
||||
showSuccess.value = true
|
||||
},
|
||||
onError: (err: any) => {
|
||||
const data = err.response?.data
|
||||
if (data?.errors) {
|
||||
errors.value = Object.fromEntries(
|
||||
Object.entries(data.errors).map(([k, v]) => [k, (v as string[])[0]]),
|
||||
)
|
||||
}
|
||||
else if (data?.message) {
|
||||
errors.value = { name: data.message }
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VDialog
|
||||
v-model="modelValue"
|
||||
max-width="550"
|
||||
>
|
||||
<VCard title="Persoon bewerken">
|
||||
<VCardText>
|
||||
<VForm
|
||||
ref="refVForm"
|
||||
@submit.prevent="onSubmit"
|
||||
>
|
||||
<VRow>
|
||||
<VCol cols="12">
|
||||
<AppSelect
|
||||
v-model="form.crowd_type_id"
|
||||
label="Crowd Type"
|
||||
:items="crowdTypeItems"
|
||||
:rules="[requiredValidator]"
|
||||
:error-messages="errors.crowd_type_id"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
<AppTextField
|
||||
v-model="form.name"
|
||||
label="Naam"
|
||||
:rules="[requiredValidator]"
|
||||
:error-messages="errors.name"
|
||||
autofocus
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
<AppTextField
|
||||
v-model="form.email"
|
||||
label="E-mailadres"
|
||||
type="email"
|
||||
:rules="[requiredValidator, emailValidator]"
|
||||
:error-messages="errors.email"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
<AppTextField
|
||||
v-model="form.phone"
|
||||
label="Telefoonnummer"
|
||||
:error-messages="errors.phone"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol
|
||||
cols="12"
|
||||
md="6"
|
||||
>
|
||||
<AppSelect
|
||||
v-model="form.status"
|
||||
label="Status"
|
||||
:items="statusOptions"
|
||||
:error-messages="errors.status"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol
|
||||
cols="12"
|
||||
md="6"
|
||||
>
|
||||
<VSwitch
|
||||
v-model="form.is_blacklisted"
|
||||
label="Geblokkeerd"
|
||||
color="error"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
<VTextarea
|
||||
v-model="form.admin_notes"
|
||||
label="Admin notities"
|
||||
variant="outlined"
|
||||
rows="3"
|
||||
:error-messages="errors.admin_notes"
|
||||
/>
|
||||
</VCol>
|
||||
</VRow>
|
||||
</VForm>
|
||||
</VCardText>
|
||||
<VCardActions>
|
||||
<VSpacer />
|
||||
<VBtn
|
||||
variant="text"
|
||||
@click="modelValue = false"
|
||||
>
|
||||
Annuleren
|
||||
</VBtn>
|
||||
<VBtn
|
||||
color="primary"
|
||||
:loading="isPending"
|
||||
@click="onSubmit"
|
||||
>
|
||||
Opslaan
|
||||
</VBtn>
|
||||
</VCardActions>
|
||||
</VCard>
|
||||
</VDialog>
|
||||
|
||||
<VSnackbar
|
||||
v-model="showSuccess"
|
||||
color="success"
|
||||
:timeout="3000"
|
||||
>
|
||||
Persoon bijgewerkt
|
||||
</VSnackbar>
|
||||
</template>
|
||||
Reference in New Issue
Block a user