Skip to content

Commit 4084588

Browse files
Refactor: Extract mapLandingSettings to reduce duplication
Co-authored-by: danielswiatek <9080990+danielswiatek@users.noreply.github.com>
1 parent d7830e0 commit 4084588

1 file changed

Lines changed: 21 additions & 30 deletions

File tree

apps/frontend/src/components/forms/unterveranstaltung/FormUnterveranstaltungLandingSettings.vue

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ const props = defineProps<{
4747
onUpdate?: () => void
4848
}>()
4949
50+
// Helper function to map landing settings from prop
51+
function mapLandingSettings(settings: any) {
52+
return {
53+
heroTitle: settings?.heroTitle ?? '',
54+
heroSubtitle: settings?.heroSubtitle ?? '',
55+
eventDetailsTitle: settings?.eventDetailsTitle ?? '',
56+
eventDetailsContent: settings?.eventDetailsContent ?? '',
57+
miscellaneousVisible: settings?.miscellaneousVisible ?? false,
58+
miscellaneousTitle: settings?.miscellaneousTitle ?? '',
59+
miscellaneousSubtitle: settings?.miscellaneousSubtitle ?? '',
60+
faqVisible: settings?.faqVisible ?? false,
61+
faqEmail: settings?.faqEmail ?? '',
62+
instagramVisible: settings?.instagramVisible ?? false,
63+
instagramUrl: settings?.instagramUrl ?? '',
64+
facebookVisible: settings?.facebookVisible ?? false,
65+
facebookUrl: settings?.facebookUrl ?? '',
66+
}
67+
}
68+
5069
const heroImages = ref<IHeroImages[]>(props.unterveranstaltung?.landingSettings?.heroImages ?? [])
5170
5271
const unterveranstaltungId = props.unterveranstaltung?.id
@@ -60,42 +79,14 @@ const miscellaneousItems = ref<IMiscellaneousItem[]>(
6079
6180
const showNotification = ref(false)
6281
63-
const landingSettings = ref({
64-
heroTitle: props.unterveranstaltung?.landingSettings?.heroTitle ?? '',
65-
heroSubtitle: props.unterveranstaltung?.landingSettings?.heroSubtitle ?? '',
66-
eventDetailsTitle: props.unterveranstaltung?.landingSettings?.eventDetailsTitle ?? '',
67-
eventDetailsContent: props.unterveranstaltung?.landingSettings?.eventDetailsContent ?? '',
68-
miscellaneousVisible: props.unterveranstaltung?.landingSettings?.miscellaneousVisible ?? false,
69-
miscellaneousTitle: props.unterveranstaltung?.landingSettings?.miscellaneousTitle ?? '',
70-
miscellaneousSubtitle: props.unterveranstaltung?.landingSettings?.miscellaneousSubtitle ?? '',
71-
faqVisible: props.unterveranstaltung?.landingSettings?.faqVisible ?? false,
72-
faqEmail: props.unterveranstaltung?.landingSettings?.faqEmail ?? '',
73-
instagramVisible: props.unterveranstaltung?.landingSettings?.instagramVisible ?? false,
74-
instagramUrl: props.unterveranstaltung?.landingSettings?.instagramUrl ?? '',
75-
facebookVisible: props.unterveranstaltung?.landingSettings?.facebookVisible ?? false,
76-
facebookUrl: props.unterveranstaltung?.landingSettings?.facebookUrl ?? '',
77-
})
82+
const landingSettings = ref(mapLandingSettings(props.unterveranstaltung?.landingSettings))
7883
7984
// Watch for prop changes and update local state
8085
watch(
8186
() => props.unterveranstaltung?.landingSettings,
8287
(newSettings) => {
8388
if (newSettings) {
84-
landingSettings.value = {
85-
heroTitle: newSettings.heroTitle ?? '',
86-
heroSubtitle: newSettings.heroSubtitle ?? '',
87-
eventDetailsTitle: newSettings.eventDetailsTitle ?? '',
88-
eventDetailsContent: newSettings.eventDetailsContent ?? '',
89-
miscellaneousVisible: newSettings.miscellaneousVisible ?? false,
90-
miscellaneousTitle: newSettings.miscellaneousTitle ?? '',
91-
miscellaneousSubtitle: newSettings.miscellaneousSubtitle ?? '',
92-
faqVisible: newSettings.faqVisible ?? false,
93-
faqEmail: newSettings.faqEmail ?? '',
94-
instagramVisible: newSettings.instagramVisible ?? false,
95-
instagramUrl: newSettings.instagramUrl ?? '',
96-
facebookVisible: newSettings.facebookVisible ?? false,
97-
facebookUrl: newSettings.facebookUrl ?? '',
98-
}
89+
landingSettings.value = mapLandingSettings(newSettings)
9990
heroImages.value = newSettings.heroImages ?? []
10091
miscellaneousItems.value = newSettings.miscellaneousItems ?? []
10192
deletedHeroImagesIds.value = []

0 commit comments

Comments
 (0)