22import { ref , watch } from ' vue'
33import { usePage } from ' @inertiajs/vue3'
44import { Check , CircleX , Info , TriangleAlert , Megaphone } from ' lucide-vue-next'
5+ import { FlashProps } from ' @/types'
56
67const page = usePage ()
78const flashed = ref (0 )
89
10+ const clearFlash = (type : keyof FlashProps ) => {
11+ if (page .props .flash ?.[type ]) {
12+ page .props .flash [type ] = null
13+ }
14+ }
15+
916watch (() => page .props .flash , () => {
1017 flashed .value ++
1118}, { deep: true })
@@ -21,6 +28,7 @@ watch(() => page.props.flash, () => {
2128 class =" mb-6"
2229 severity =" success"
2330 closable
31+ @close =" clearFlash('success')"
2432 >
2533 <template #icon >
2634 <Check />
@@ -32,6 +40,7 @@ watch(() => page.props.flash, () => {
3240 class =" mb-6"
3341 severity =" info"
3442 closable
43+ @close =" clearFlash('info')"
3544 >
3645 <template #icon >
3746 <Info />
@@ -43,6 +52,7 @@ watch(() => page.props.flash, () => {
4352 class =" mb-6"
4453 severity =" warn"
4554 closable
55+ @close =" clearFlash('warn')"
4656 >
4757 <template #icon >
4858 <TriangleAlert />
@@ -54,6 +64,7 @@ watch(() => page.props.flash, () => {
5464 class =" mb-6"
5565 severity =" error"
5666 closable
67+ @close =" clearFlash('error')"
5768 >
5869 <template #icon >
5970 <CircleX />
@@ -65,6 +76,7 @@ watch(() => page.props.flash, () => {
6576 class =" mb-6"
6677 severity =" secondary"
6778 closable
79+ @close =" clearFlash('message')"
6880 >
6981 <template #icon >
7082 <Megaphone />
0 commit comments