| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <div> | 
					
						
							|  |  |  |     <v-card-text> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       <v-switch | 
					
						
							|  |  |  |         v-model="webhookCopy.enabled" | 
					
						
							|  |  |  |         color="primary" | 
					
						
							|  |  |  |         :label="$t('general.enabled')" | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |       <v-text-field | 
					
						
							|  |  |  |         v-model="webhookCopy.name" | 
					
						
							|  |  |  |         :label="$t('settings.webhooks.webhook-name')" | 
					
						
							|  |  |  |         variant="underlined" | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |       <v-text-field | 
					
						
							|  |  |  |         v-model="webhookCopy.url" | 
					
						
							|  |  |  |         :label="$t('settings.webhooks.webhook-url')" | 
					
						
							|  |  |  |         variant="underlined" | 
					
						
							|  |  |  |       /> | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  |       <v-text-field | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         v-model="scheduledTime" | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  |         type="time" | 
					
						
							|  |  |  |         clearable | 
					
						
							|  |  |  |         variant="underlined" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       /> | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  |     </v-card-text> | 
					
						
							|  |  |  |     <v-card-actions class="py-0 justify-end"> | 
					
						
							|  |  |  |       <BaseButtonGroup | 
					
						
							|  |  |  |         :buttons="[ | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             icon: $globals.icons.delete, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             text: $t('general.delete'), | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  |             event: 'delete', | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             icon: $globals.icons.testTube, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             text: $t('general.test'), | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  |             event: 'test', | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             icon: $globals.icons.save, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             text: $t('general.save'), | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  |             event: 'save', | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |         ]" | 
					
						
							|  |  |  |         @delete="$emit('delete', webhookCopy.id)" | 
					
						
							|  |  |  |         @save="handleSave" | 
					
						
							|  |  |  |         @test="$emit('test', webhookCopy.id)" | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |     </v-card-actions> | 
					
						
							|  |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  | <script setup lang="ts"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { ReadWebhook } from "~/lib/api/types/household"; | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  | import { timeLocalToUTC, timeUTCToLocal } from "~/composables/use-group-webhooks"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  | const props = defineProps<{ | 
					
						
							|  |  |  |   webhook: ReadWebhook; | 
					
						
							|  |  |  | }>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const emit = defineEmits<{ | 
					
						
							|  |  |  |   delete: [id: string]; | 
					
						
							|  |  |  |   save: [webhook: ReadWebhook]; | 
					
						
							|  |  |  |   test: [id: string]; | 
					
						
							|  |  |  | }>(); | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  | const i18n = useI18n(); | 
					
						
							|  |  |  | const itemUTC = ref<string>(props.webhook.scheduledTime); | 
					
						
							|  |  |  | const itemLocal = ref<string>(timeUTCToLocal(props.webhook.scheduledTime)); | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  | const scheduledTime = computed({ | 
					
						
							|  |  |  |   get() { | 
					
						
							|  |  |  |     return itemLocal.value; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   set(v: string) { | 
					
						
							|  |  |  |     itemUTC.value = timeLocalToUTC(v); | 
					
						
							|  |  |  |     itemLocal.value = v; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  | const webhookCopy = ref({ ...props.webhook }); | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  | function handleSave() { | 
					
						
							|  |  |  |   webhookCopy.value.scheduledTime = itemLocal.value; | 
					
						
							|  |  |  |   emit("save", webhookCopy.value); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 02:05:26 +02:00
										 |  |  | // Set page title using useSeoMeta
 | 
					
						
							|  |  |  | useSeoMeta({ | 
					
						
							|  |  |  |   title: i18n.t("settings.webhooks.webhooks"), | 
					
						
							| 
									
										
										
										
											2022-06-17 13:25:47 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | </script> |