From e473f747372d9f399ef654c400e5940f2d9cfa03 Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Fri, 30 Jun 2023 14:33:43 -0400 Subject: [PATCH 1/5] do not handle error if vehicle lookup is successful --- src/layouts/policy-vehicles/policy-vehicles.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 4a92c1c2..43971e91 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -193,7 +193,7 @@ export default { const vehicle = await this.lookupVehicleByVin(value); // handle error in case vehicle info doesn't come back for selected VIN - if (vehicle?.error ?? true) { + if (vehicle?.error === true) { this.mainStore.resetVehicleState(); this.displayGeneric = true; return; From 33a617ea25bfb5352dff9e3ba19ec4753335016a Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Fri, 30 Jun 2023 14:41:24 -0400 Subject: [PATCH 2/5] handle nulls --- src/layouts/policy-vehicles/policy-vehicles.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 43971e91..0444498f 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -200,14 +200,14 @@ export default { } // save selected vehicle to the store - this.mainStore.updateVehicle(vehicle.data); + this.mainStore.updateVehicle(vehicle?.data); this.displayGeneric = true; // get the style(s) associated with the selected YMM const styleOptions = await this.mainStore.getVehicleStyles( - vehicle.data.year, - vehicle.data.make, - vehicle.data.model + vehicle?.data.year, + vehicle?.data.make, + vehicle?.data.model ) // if there is more than 1 style for the selected vehicle, display generic/blurred image From fd1f630677966f9ee56ded503f2e0a030bd6dbfe Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Mon, 3 Jul 2023 14:13:13 -0400 Subject: [PATCH 3/5] refactor --- .../policy-vehicles/policy-vehicles.vue | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 0444498f..fd7a8c52 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -194,24 +194,22 @@ export default { // handle error in case vehicle info doesn't come back for selected VIN if (vehicle?.error === true) { - this.mainStore.resetVehicleState(); - this.displayGeneric = true; - return; + this.mainStore.resetVehicleState(); + this.displayGeneric = true; + } else { + // save selected vehicle to the store + this.mainStore.updateVehicle(vehicle?.data); + this.displayGeneric = true; + + // get the style(s) associated with the selected YMM + const styleOptions = await this.mainStore.getVehicleStyles( + vehicle.data.year, + vehicle.data.make, + vehicle.data.model, + ); + // if there is more than 1 style for the selected vehicle, display generic/blurred image + this.displayGeneric = styleOptions?.data?.length > 1; } - - // save selected vehicle to the store - this.mainStore.updateVehicle(vehicle?.data); - this.displayGeneric = true; - - // get the style(s) associated with the selected YMM - const styleOptions = await this.mainStore.getVehicleStyles( - vehicle?.data.year, - vehicle?.data.make, - vehicle?.data.model - ) - - // if there is more than 1 style for the selected vehicle, display generic/blurred image - this.displayGeneric = styleOptions?.data?.length > 1; } } }, From 3485373a4c637bc4e40a078ab1617cedfe638d5c Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Mon, 3 Jul 2023 14:25:40 -0400 Subject: [PATCH 4/5] refactor v2 --- src/layouts/policy-vehicles/policy-vehicles.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index fd7a8c52..e847e94b 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -196,9 +196,10 @@ export default { if (vehicle?.error === true) { this.mainStore.resetVehicleState(); this.displayGeneric = true; - } else { + } + if (vehicle) { // save selected vehicle to the store - this.mainStore.updateVehicle(vehicle?.data); + this.mainStore.updateVehicle(vehicle); this.displayGeneric = true; // get the style(s) associated with the selected YMM From b767f162ba498ecf9a9100c447819cb274c83f85 Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Mon, 3 Jul 2023 14:38:36 -0400 Subject: [PATCH 5/5] final refactor --- src/layouts/policy-vehicles/policy-vehicles.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index e847e94b..3466f5b9 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -196,12 +196,13 @@ export default { if (vehicle?.error === true) { this.mainStore.resetVehicleState(); this.displayGeneric = true; + return; } if (vehicle) { // save selected vehicle to the store - this.mainStore.updateVehicle(vehicle); + this.mainStore.updateVehicle(vehicle.data); this.displayGeneric = true; - + // get the style(s) associated with the selected YMM const styleOptions = await this.mainStore.getVehicleStyles( vehicle.data.year,