Skip to content

Commit

Permalink
Merge branch 'v3' into feat/settings-v3
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac authored Feb 19, 2025
2 parents b56d85c + 34c0b4b commit 429eea4
Show file tree
Hide file tree
Showing 7 changed files with 529 additions and 127 deletions.
3 changes: 0 additions & 3 deletions app/components/NotificationsSlideover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ const { data: notifications } = await useFetch<Notification[]>('/api/notificatio
<USlideover
v-model:open="isNotificationsSlideoverOpen"
title="Notifications"
:ui="{
header: 'h-(--ui-header-height)'
}"
>
<template #body>
<NuxtLink
Expand Down
59 changes: 59 additions & 0 deletions app/components/customers/AddModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<script setup lang="ts">
import * as z from 'zod'
import type { FormSubmitEvent } from '@nuxt/ui'
const schema = z.object({
name: z.string().min(2, 'Too short'),
email: z.string().email('Invalid email')
})
const open = ref(false)
type Schema = z.output<typeof schema>
const state = reactive<Partial<Schema>>({
name: undefined,
email: undefined
})
const toast = useToast()
async function onSubmit(event: FormSubmitEvent<Schema>) {
toast.add({ title: 'Success', description: `New customer ${event.data.name} added`, color: 'success' })
open.value = false
}
</script>

<template>
<UModal v-model:open="open" title="New customer" description="Add a new customer to the database">
<UButton label="New customer" icon="i-lucide-plus" />

<template #body>
<UForm
:schema="schema"
:state="state"
class="space-y-4"
@submit="onSubmit"
>
<UFormField label="Name" placeholder="John Doe" name="name">
<UInput v-model="state.name" class="w-full" />
</UFormField>
<UFormField label="Email" placeholder="[email protected]" name="email">
<UInput v-model="state.email" class="w-full" />
</UFormField>
<div class="flex justify-end gap-2">
<UButton
label="Cancel"
color="neutral"
variant="subtle"
@click="open = false"
/>
<UButton
label="Create"
color="primary"
variant="solid"
type="submit"
/>
</div>
</UForm>
</template>
</UModal>
</template>
40 changes: 40 additions & 0 deletions app/components/customers/DeleteModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script setup lang="ts">
defineProps<{
nbCustomers: number
}>()
const open = ref(false)
async function onSubmit() {
await new Promise(resolve => setTimeout(resolve, 1000))
open.value = false
}
</script>

<template>
<UModal
v-model:open="open"
:title="`Delete ${nbCustomers} customer${nbCustomers > 1 ? 's' : ''}`"
:description="`Are you sure, this action cannot be undone.`"
>
<slot />

<template #body>
<div class="flex justify-end gap-2">
<UButton
label="Cancel"
color="neutral"
variant="subtle"
@click="open = false"
/>
<UButton
label="Delete"
color="error"
variant="solid"
loading-auto
@click="onSubmit"
/>
</div>
</template>
</UModal>
</template>
Loading

0 comments on commit 429eea4

Please sign in to comment.