From 3e721f7626477844dfe5b92027c247e1f6eeaa88 Mon Sep 17 00:00:00 2001 From: David Mendy Date: Mon, 27 May 2024 17:44:42 +0200 Subject: [PATCH] refactor: :recycle: refactor typologies files --- .../SecuringTutorialContent.vue | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/frontend/src/views/GuideSecuringFirearm/SecuringTutorialContent.vue b/frontend/src/views/GuideSecuringFirearm/SecuringTutorialContent.vue index 4cc21215..04d16714 100644 --- a/frontend/src/views/GuideSecuringFirearm/SecuringTutorialContent.vue +++ b/frontend/src/views/GuideSecuringFirearm/SecuringTutorialContent.vue @@ -26,24 +26,25 @@ const selectedOptionStep = computed(() => { }) const options = TYPOLOGIES.revolver?.securingSteps?.steps[1]?.options.concat(TYPOLOGIES.revolver?.securingSteps?.steps[2]?.options) -const matchingOption = options.find(option => option.value.toString() === selectedOptionStep.value) -let selectedOption = '' -const selectedOptionVideos = computed(() => { - if (options && selectedOptionStep.value) { - selectedOption = matchingOption ? matchingOption.video : '' +const getSelectedOptionData = (options) => { + const matchingOption = options.find(option => option.value.toString() === selectedOptionStep.value) + const selectedOption = { + video: '', + texts: '', } - return selectedOption -}) - -const selectedOptionTexts = computed(() => { - if (options && selectedOptionStep.value) { - selectedOption = matchingOption ? matchingOption.text_steps : '' + if (matchingOption) { + selectedOption.video = matchingOption.video || '' + selectedOption.texts = matchingOption.text_steps || '' } return selectedOption -}) +} + +const selectedOptionVideos = getSelectedOptionData(options).video +const selectedOptionTexts = getSelectedOptionData(options).texts +