| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |   <div> | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  |     <div> | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |       <BaseDialog | 
					
						
							|  |  |  |         v-model="madeThisDialog" | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  |         :loading="madeThisFormLoading" | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |         :icon="$globals.icons.chefHat" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         :title="$t('recipe.made-this')" | 
					
						
							|  |  |  |         :submit-text="$t('recipe.add-to-timeline')" | 
					
						
							|  |  |  |         can-submit | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |         @submit="createTimelineEvent" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       > | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |         <v-card-text> | 
					
						
							|  |  |  |           <v-form ref="domMadeThisForm"> | 
					
						
							|  |  |  |             <v-textarea | 
					
						
							|  |  |  |               v-model="newTimelineEvent.eventMessage" | 
					
						
							|  |  |  |               autofocus | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |               :label="$t('recipe.comment')" | 
					
						
							|  |  |  |               :hint="$t('recipe.how-did-it-turn-out')" | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |               persistent-hint | 
					
						
							|  |  |  |               rows="4" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             /> | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |             <v-container> | 
					
						
							|  |  |  |               <v-row> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                 <v-col cols="6"> | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                   <v-menu | 
					
						
							|  |  |  |                     v-model="datePickerMenu" | 
					
						
							|  |  |  |                     :close-on-content-click="false" | 
					
						
							|  |  |  |                     transition="scale-transition" | 
					
						
							|  |  |  |                     offset-y | 
					
						
							|  |  |  |                     max-width="290px" | 
					
						
							|  |  |  |                   > | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |                     <template #activator="{ props: activatorProps }"> | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                       <v-text-field | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                         v-model="newTimelineEventTimestampString" | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                         :prepend-icon="$globals.icons.calendar" | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |                         v-bind="activatorProps" | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                         readonly | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                       /> | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                     </template> | 
					
						
							|  |  |  |                     <v-date-picker | 
					
						
							|  |  |  |                       v-model="newTimelineEventTimestamp" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                       hide-header | 
					
						
							| 
									
										
										
										
											2024-03-12 17:46:34 -05:00
										 |  |  |                       :first-day-of-week="firstDayOfWeek" | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                       :local="$i18n.locale" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                       @update:model-value="datePickerMenu = false" | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                     /> | 
					
						
							|  |  |  |                   </v-menu> | 
					
						
							|  |  |  |                 </v-col> | 
					
						
							|  |  |  |                 <v-spacer /> | 
					
						
							|  |  |  |                 <v-col cols="auto" align-self="center"> | 
					
						
							|  |  |  |                   <AppButtonUpload | 
					
						
							| 
									
										
										
										
											2023-08-21 10:00:37 -05:00
										 |  |  |                     v-if="!newTimelineEventImage" | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                     class="ml-auto" | 
					
						
							|  |  |  |                     url="none" | 
					
						
							|  |  |  |                     file-name="image" | 
					
						
							|  |  |  |                     accept="image/*" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                     :text="$t('recipe.upload-image')" | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                     :text-btn="false" | 
					
						
							|  |  |  |                     :post="false" | 
					
						
							|  |  |  |                     @uploaded="uploadImage" | 
					
						
							|  |  |  |                   /> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                   <v-btn v-if="!!newTimelineEventImage" color="error" @click="clearImage"> | 
					
						
							|  |  |  |                     <v-icon start> | 
					
						
							|  |  |  |                       {{ $globals.icons.close }} | 
					
						
							|  |  |  |                     </v-icon> | 
					
						
							|  |  |  |                     {{ $t("recipe.remove-image") }} | 
					
						
							| 
									
										
										
										
											2023-08-21 10:00:37 -05:00
										 |  |  |                   </v-btn> | 
					
						
							|  |  |  |                 </v-col> | 
					
						
							|  |  |  |               </v-row> | 
					
						
							|  |  |  |               <v-row v-if="newTimelineEventImage && newTimelineEventImagePreviewUrl"> | 
					
						
							|  |  |  |                 <v-col cols="12" align-self="center"> | 
					
						
							|  |  |  |                   <ImageCropper | 
					
						
							|  |  |  |                     :img="newTimelineEventImagePreviewUrl" | 
					
						
							|  |  |  |                     cropper-height="20vh" | 
					
						
							|  |  |  |                     cropper-width="100%" | 
					
						
							|  |  |  |                     @save="updateUploadedImage" | 
					
						
							|  |  |  |                   /> | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  |                 </v-col> | 
					
						
							|  |  |  |               </v-row> | 
					
						
							|  |  |  |             </v-container> | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |           </v-form> | 
					
						
							|  |  |  |         </v-card-text> | 
					
						
							|  |  |  |       </BaseDialog> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |     <div> | 
					
						
							| 
									
										
										
										
											2025-02-26 17:07:12 +01:00
										 |  |  |       <div v-if="lastMadeReady" class="d-flex justify-center flex-wrap"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <v-row no-gutters class="d-flex flex-wrap align-center" style="font-size: larger"> | 
					
						
							| 
									
										
										
										
											2025-07-29 16:53:33 -05:00
										 |  |  |           <v-tooltip location="bottom"> | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |             <template #activator="{ props: tooltipProps }"> | 
					
						
							| 
									
										
										
										
											2025-02-26 17:07:12 +01:00
										 |  |  |               <v-btn | 
					
						
							|  |  |  |                 rounded | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                 variant="outlined" | 
					
						
							|  |  |  |                 size="x-large" | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |                 v-bind="tooltipProps" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                 style="border-color: rgb(var(--v-theme-primary));" | 
					
						
							| 
									
										
										
										
											2025-02-26 17:07:12 +01:00
										 |  |  |                 @click="madeThisDialog = true" | 
					
						
							|  |  |  |               > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                 <v-icon start size="large" color="primary"> | 
					
						
							|  |  |  |                   {{ $globals.icons.calendar }} | 
					
						
							|  |  |  |                 </v-icon> | 
					
						
							|  |  |  |                 <span class="text-body-1 opacity-80"> | 
					
						
							|  |  |  |                   <b>{{ $t("general.last-made") }}</b> | 
					
						
							|  |  |  |                   <br> | 
					
						
							|  |  |  |                   {{ lastMade ? new Date(lastMade).toLocaleDateString($i18n.locale) : $t("general.never") }} | 
					
						
							|  |  |  |                 </span> | 
					
						
							|  |  |  |                 <v-icon end size="large" color="primary"> | 
					
						
							|  |  |  |                   {{ $globals.icons.createAlt }} | 
					
						
							|  |  |  |                 </v-icon> | 
					
						
							| 
									
										
										
										
											2025-02-26 17:07:12 +01:00
										 |  |  |               </v-btn> | 
					
						
							|  |  |  |             </template> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             <span>{{ $t("recipe.made-this") }}</span> | 
					
						
							| 
									
										
										
										
											2025-02-26 17:07:12 +01:00
										 |  |  |           </v-tooltip> | 
					
						
							|  |  |  |         </v-row> | 
					
						
							| 
									
										
										
										
											2024-11-20 08:46:27 -06:00
										 |  |  |       </div> | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  |     </div> | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | <script setup lang="ts"> | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  | import { whenever } from "@vueuse/core"; | 
					
						
							| 
									
										
										
										
											2025-09-02 00:44:30 +09:00
										 |  |  | import { formatISO } from "date-fns"; | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  | import { useUserApi } from "~/composables/api"; | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  | import { alert } from "~/composables/use-toast"; | 
					
						
							| 
									
										
										
										
											2024-08-22 10:14:32 -05:00
										 |  |  | import { useHouseholdSelf } from "~/composables/use-households"; | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  | import type { Recipe, RecipeTimelineEventIn, RecipeTimelineEventOut } from "~/lib/api/types/recipe"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { VForm } from "~/types/auto-forms"; | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | const props = defineProps<{ recipe: Recipe }>(); | 
					
						
							|  |  |  | const emit = defineEmits<{ | 
					
						
							|  |  |  |   eventCreated: [event: RecipeTimelineEventOut]; | 
					
						
							|  |  |  | }>(); | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | const madeThisDialog = ref(false); | 
					
						
							|  |  |  | const userApi = useUserApi(); | 
					
						
							|  |  |  | const { household } = useHouseholdSelf(); | 
					
						
							|  |  |  | const i18n = useI18n(); | 
					
						
							|  |  |  | const $auth = useMealieAuth(); | 
					
						
							|  |  |  | const domMadeThisForm = ref<VForm>(); | 
					
						
							|  |  |  | const newTimelineEvent = ref<RecipeTimelineEventIn>({ | 
					
						
							|  |  |  |   subject: "", | 
					
						
							|  |  |  |   eventType: "comment", | 
					
						
							|  |  |  |   eventMessage: "", | 
					
						
							|  |  |  |   timestamp: undefined, | 
					
						
							|  |  |  |   recipeId: props.recipe?.id || "", | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | const newTimelineEventImage = ref<Blob | File>(); | 
					
						
							|  |  |  | const newTimelineEventImageName = ref<string>(""); | 
					
						
							|  |  |  | const newTimelineEventImagePreviewUrl = ref<string>(); | 
					
						
							|  |  |  | const newTimelineEventTimestamp = ref<Date>(new Date()); | 
					
						
							|  |  |  | const newTimelineEventTimestampString = computed(() => { | 
					
						
							| 
									
										
										
										
											2025-09-02 00:44:30 +09:00
										 |  |  |   return formatISO(newTimelineEventTimestamp.value, { representation: "date" }); | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2025-01-13 10:19:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | const lastMade = ref(props.recipe.lastMade); | 
					
						
							|  |  |  | const lastMadeReady = ref(false); | 
					
						
							|  |  |  | onMounted(async () => { | 
					
						
							|  |  |  |   if (!$auth.user?.value?.householdSlug) { | 
					
						
							|  |  |  |     lastMade.value = props.recipe.lastMade; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     const { data } = await userApi.households.getCurrentUserHouseholdRecipe(props.recipe.slug || ""); | 
					
						
							|  |  |  |     lastMade.value = data?.lastMade; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-01-13 10:19:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   lastMadeReady.value = true; | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | whenever( | 
					
						
							|  |  |  |   () => madeThisDialog.value, | 
					
						
							|  |  |  |   () => { | 
					
						
							|  |  |  |     // Set timestamp to now
 | 
					
						
							| 
									
										
										
										
											2025-09-02 00:44:30 +09:00
										 |  |  |     newTimelineEventTimestamp.value = new Date(); | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   }, | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2024-03-12 17:46:34 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | const firstDayOfWeek = computed(() => { | 
					
						
							|  |  |  |   return household.value?.preferences?.firstDayOfWeek || 0; | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2023-08-21 10:00:37 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | function clearImage() { | 
					
						
							|  |  |  |   newTimelineEventImage.value = undefined; | 
					
						
							|  |  |  |   newTimelineEventImageName.value = ""; | 
					
						
							|  |  |  |   newTimelineEventImagePreviewUrl.value = undefined; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-08-21 10:00:37 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | function uploadImage(fileObject: File) { | 
					
						
							|  |  |  |   newTimelineEventImage.value = fileObject; | 
					
						
							|  |  |  |   newTimelineEventImageName.value = fileObject.name; | 
					
						
							|  |  |  |   newTimelineEventImagePreviewUrl.value = URL.createObjectURL(fileObject); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | function updateUploadedImage(fileObject: Blob) { | 
					
						
							|  |  |  |   newTimelineEventImage.value = fileObject; | 
					
						
							|  |  |  |   newTimelineEventImagePreviewUrl.value = URL.createObjectURL(fileObject); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | const datePickerMenu = ref(false); | 
					
						
							|  |  |  | const madeThisFormLoading = ref(false); | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | function resetMadeThisForm() { | 
					
						
							|  |  |  |   madeThisFormLoading.value = false; | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   newTimelineEvent.value.eventMessage = ""; | 
					
						
							|  |  |  |   newTimelineEvent.value.timestamp = undefined; | 
					
						
							|  |  |  |   clearImage(); | 
					
						
							|  |  |  |   madeThisDialog.value = false; | 
					
						
							|  |  |  |   domMadeThisForm.value?.reset(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | async function createTimelineEvent() { | 
					
						
							|  |  |  |   if (!(newTimelineEventTimestampString.value && props.recipe?.id && props.recipe?.slug)) { | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   madeThisFormLoading.value = true; | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   newTimelineEvent.value.recipeId = props.recipe.id; | 
					
						
							|  |  |  |   // Note: $auth.user is now a ref
 | 
					
						
							|  |  |  |   newTimelineEvent.value.subject = i18n.t("recipe.user-made-this", { user: $auth.user.value?.fullName }); | 
					
						
							| 
									
										
										
										
											2023-08-06 12:49:30 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   // the user only selects the date, so we set the time to end of day local time
 | 
					
						
							|  |  |  |   // we choose the end of day so it always comes after "new recipe" events
 | 
					
						
							|  |  |  |   newTimelineEvent.value.timestamp = new Date(newTimelineEventTimestampString.value + "T23:59:59").toISOString(); | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   let newEvent: RecipeTimelineEventOut | null = null; | 
					
						
							|  |  |  |   try { | 
					
						
							|  |  |  |     const eventResponse = await userApi.recipes.createTimelineEvent(newTimelineEvent.value); | 
					
						
							|  |  |  |     newEvent = eventResponse.data; | 
					
						
							|  |  |  |     if (!newEvent) { | 
					
						
							|  |  |  |       throw new Error("No event created"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   catch (error) { | 
					
						
							|  |  |  |     console.error("Failed to create timeline event:", error); | 
					
						
							|  |  |  |     alert.error(i18n.t("recipe.failed-to-add-to-timeline")); | 
					
						
							|  |  |  |     resetMadeThisForm(); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   // we also update the recipe's last made value
 | 
					
						
							|  |  |  |   if (!lastMade.value || newTimelineEvent.value.timestamp > lastMade.value) { | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       lastMade.value = newTimelineEvent.value.timestamp; | 
					
						
							|  |  |  |       await userApi.recipes.updateLastMade(props.recipe.slug, newTimelineEvent.value.timestamp); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     catch (error) { | 
					
						
							|  |  |  |       console.error("Failed to update last made date:", error); | 
					
						
							|  |  |  |       alert.error(i18n.t("recipe.failed-to-update-recipe")); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   // update the image, if provided
 | 
					
						
							|  |  |  |   let imageError = false; | 
					
						
							|  |  |  |   if (newTimelineEventImage.value) { | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       const imageResponse = await userApi.recipes.updateTimelineEventImage( | 
					
						
							|  |  |  |         newEvent.id, | 
					
						
							|  |  |  |         newTimelineEventImage.value, | 
					
						
							|  |  |  |         newTimelineEventImageName.value, | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |       if (imageResponse.data) { | 
					
						
							|  |  |  |         newEvent.image = imageResponse.data.image; | 
					
						
							| 
									
										
										
										
											2025-07-25 07:18:10 -05:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |     catch (error) { | 
					
						
							|  |  |  |       imageError = true; | 
					
						
							|  |  |  |       console.error("Failed to upload image for timeline event:", error); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-11-13 17:12:53 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   if (imageError) { | 
					
						
							|  |  |  |     alert.error(i18n.t("recipe.added-to-timeline-but-failed-to-add-image")); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     alert.success(i18n.t("recipe.added-to-timeline")); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   resetMadeThisForm(); | 
					
						
							|  |  |  |   emit("eventCreated", newEvent); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  | </script> |