Added code to call image to vin service
This commit is contained in:
parent
785203c0f8
commit
ffb3c01693
5 changed files with 82 additions and 30 deletions
|
|
@ -6,7 +6,12 @@
|
|||
class="form-label"
|
||||
:class="[questionAlignment === 'center' ? 'text-center w-100 mb-5' : '']"
|
||||
v-html="labelText"></label>
|
||||
<div class="input-wrapper" :class="[includeSearchIcon ? 'has-search-icon' : '', includeCameraIcon ? 'has-camera-icon' : '']">
|
||||
<div
|
||||
class="input-wrapper"
|
||||
:class="[
|
||||
includeSearchIcon ? 'has-search-icon' : '',
|
||||
includeCameraIcon ? 'has-camera-icon' : '',
|
||||
]">
|
||||
<input
|
||||
class="form-control"
|
||||
v-model.trim="value"
|
||||
|
|
@ -32,7 +37,12 @@
|
|||
@focus="$emit('focus', $event.target.value)" />
|
||||
<button v-if="includeSearchIcon" type="submit" aria-label="Search button" />
|
||||
<label class="camera-icon-input" v-if="includeCameraIcon">
|
||||
<input type="file" id="vin-input" accept="image/*" aria-label="Camera icon/button" />
|
||||
<input
|
||||
type="file"
|
||||
id="vin-input"
|
||||
accept="image/*"
|
||||
aria-label="Camera icon/button"
|
||||
@change="submitImage" />
|
||||
</label>
|
||||
</div>
|
||||
<div v-show="errorMessage" class="row my-2 form-test-error">
|
||||
|
|
@ -43,6 +53,7 @@
|
|||
|
||||
<script>
|
||||
import { useField, validate } from "vee-validate";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
|
||||
export default {
|
||||
name: "textbox-question",
|
||||
|
|
@ -109,6 +120,18 @@ export default {
|
|||
errors,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async submitImage(e) {
|
||||
await this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_IMAGE, e.target.files[0])
|
||||
.then((response) => {
|
||||
document.getElementById(this.inputId).value = response.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
e.target.value = null;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
questionText() {
|
||||
return this.getCmsContent(this.cmsWidgetName, "QuestionText");
|
||||
|
|
@ -187,30 +210,30 @@ export default {
|
|||
}
|
||||
}
|
||||
&.has-camera-icon {
|
||||
label {
|
||||
&.camera-icon-input {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
right: 1rem;
|
||||
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 40 36' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M19.9774 16.5228C17.3559 16.5228 15.1864 18.6621 15.1864 21.3476C15.1864 24.0331 17.3107 26.1724 19.9774 26.1724C22.6441 26.1724 24.7684 24.0331 24.7684 21.3476C24.7684 18.6621 22.6441 16.5228 19.9774 16.5228Z' fill='%231574A1'/%3E%3Cpath d='M38.4181 7.23725H29.8701C29.1469 2.64 24.7684 0 19.9774 0C15.1864 0 10.8531 2.64 10.0847 7.23725H1.58192C0.723164 7.23725 0 7.96553 0 8.83035V33.7738C0 34.6387 0.723164 35.3669 1.58192 35.3669H38.4181C39.2768 35.3669 40 34.6387 40 33.7738V8.83035C40 7.96553 39.2768 7.23725 38.4181 7.23725ZM19.9774 29.7683C15.3672 29.7683 11.5706 25.9904 11.5706 21.3021C11.5706 16.6138 15.3672 12.8814 19.9774 12.8814C24.5876 12.8814 28.3842 16.6593 28.3842 21.3476C28.3842 26.0359 24.6328 29.7683 19.9774 29.7683ZM36.565 14.5655H33.0395V11.0152H36.565V14.5655Z' fill='%231574A1'/%3E%3C/svg%3E%0A");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
width: 2rem;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
input[type="file"] {
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
label {
|
||||
&.camera-icon-input {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
right: 1rem;
|
||||
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 40 36' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M19.9774 16.5228C17.3559 16.5228 15.1864 18.6621 15.1864 21.3476C15.1864 24.0331 17.3107 26.1724 19.9774 26.1724C22.6441 26.1724 24.7684 24.0331 24.7684 21.3476C24.7684 18.6621 22.6441 16.5228 19.9774 16.5228Z' fill='%231574A1'/%3E%3Cpath d='M38.4181 7.23725H29.8701C29.1469 2.64 24.7684 0 19.9774 0C15.1864 0 10.8531 2.64 10.0847 7.23725H1.58192C0.723164 7.23725 0 7.96553 0 8.83035V33.7738C0 34.6387 0.723164 35.3669 1.58192 35.3669H38.4181C39.2768 35.3669 40 34.6387 40 33.7738V8.83035C40 7.96553 39.2768 7.23725 38.4181 7.23725ZM19.9774 29.7683C15.3672 29.7683 11.5706 25.9904 11.5706 21.3021C11.5706 16.6138 15.3672 12.8814 19.9774 12.8814C24.5876 12.8814 28.3842 16.6593 28.3842 21.3476C28.3842 26.0359 24.6328 29.7683 19.9774 29.7683ZM36.565 14.5655H33.0395V11.0152H36.565V14.5655Z' fill='%231574A1'/%3E%3C/svg%3E%0A");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
width: 2rem;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
input[type="file"] {
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input {
|
||||
&.has-icon {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ const storeActions = {
|
|||
LOOKUP_VEHICLE_BY_VIN: "lookupVehicleByVin",
|
||||
LOOKUP_VIN_BY_PLATE: "lookupVinByPlate",
|
||||
LOOKUP_VIN_BY_ADDRESS: "lookupVinByAddress",
|
||||
LOOKUP_VIN_BY_IMAGE: "lookupVinByImage",
|
||||
GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions",
|
||||
GET_PARTS: "getParts",
|
||||
GET_WIPERS: "getWipers",
|
||||
|
|
|
|||
|
|
@ -53,6 +53,25 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
callSimpleHttpClient({ method, endpoint, payload }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios({
|
||||
method: method,
|
||||
url: endpoint,
|
||||
data: payload,
|
||||
crossDomain: true,
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
}).then(
|
||||
(response) => {
|
||||
return resolve(response);
|
||||
},
|
||||
(error) => {
|
||||
return reject(error.response);
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
/* istanbul ignore next */
|
||||
callMockHttpClient({ method, endpoint }) {
|
||||
// For Mock use only!
|
||||
|
|
|
|||
|
|
@ -529,6 +529,15 @@ export const actions = {
|
|||
},
|
||||
});
|
||||
},
|
||||
lookupVinByImage(context, image) {
|
||||
const data = new FormData();
|
||||
data.append("file", image);
|
||||
return globalMethods.callSimpleHttpClient({
|
||||
method: "POST",
|
||||
endpoint: "https://slimagetovin.azurewebsites.net/home/FindVIN",
|
||||
payload: data,
|
||||
});
|
||||
},
|
||||
getVehicleMakes(context, { year }) {
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetVehicleMakes.method,
|
||||
|
|
|
|||
|
|
@ -127,12 +127,12 @@ html {
|
|||
background-size: 16px 12px;
|
||||
}
|
||||
.has-search-icon {
|
||||
button[type="submit"] {
|
||||
background-color: $red-100;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.7817 14.7328L11.8252 10.7762C12.8833 9.45005 13.3936 7.76911 13.2513 6.07849C13.1091 4.38788 12.325 2.81587 11.0601 1.6852C9.79515 0.554524 8.14538 -0.0490261 6.44946 -0.00154744C4.75353 0.0459312 3.14012 0.740836 1.94045 1.94051C0.740775 3.14018 0.0458701 4.75359 -0.00160848 6.44952C-0.0490871 8.14545 0.554463 9.79521 1.68514 11.0601C2.81581 12.325 4.38782 13.1091 6.07843 13.2514C7.76905 13.3937 9.44999 12.8834 10.7762 11.8252L14.7349 15.7839C14.8044 15.8527 14.8869 15.907 14.9774 15.9439C15.068 15.9808 15.165 15.9995 15.2628 15.9989C15.3606 15.9983 15.4573 15.9784 15.5475 15.9405C15.6376 15.9025 15.7194 15.8471 15.7881 15.7776C15.8568 15.708 15.9112 15.6256 15.9481 15.535C15.985 15.4444 16.0036 15.3474 16.0031 15.2496C16.0025 15.1518 15.9826 15.0551 15.9446 14.965C15.9067 14.8748 15.8513 14.7931 15.7817 14.7243V14.7328ZM6.63737 11.7913C5.61803 11.7913 4.62157 11.4891 3.77402 10.9228C2.92646 10.3564 2.26587 9.5515 1.87578 8.60975C1.4857 7.668 1.38363 6.63172 1.5825 5.63196C1.78136 4.6322 2.27222 3.71386 2.99301 2.99307C3.7138 2.27229 4.63214 1.78142 5.6319 1.58256C6.63166 1.38369 7.66793 1.48576 8.60969 1.87585C9.55144 2.26593 10.3564 2.92652 10.9227 3.77408C11.489 4.62163 11.7913 5.61809 11.7913 6.63743C11.7896 8.00382 11.2461 9.31376 10.2799 10.2799C9.3137 11.2461 8.00376 11.7897 6.63737 11.7913Z' fill='%23d4281c'/%3E%3C/svg%3E%0A");
|
||||
border: 1px solid $red;
|
||||
border-left: none;
|
||||
}
|
||||
button[type="submit"] {
|
||||
background-color: $red-100;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.7817 14.7328L11.8252 10.7762C12.8833 9.45005 13.3936 7.76911 13.2513 6.07849C13.1091 4.38788 12.325 2.81587 11.0601 1.6852C9.79515 0.554524 8.14538 -0.0490261 6.44946 -0.00154744C4.75353 0.0459312 3.14012 0.740836 1.94045 1.94051C0.740775 3.14018 0.0458701 4.75359 -0.00160848 6.44952C-0.0490871 8.14545 0.554463 9.79521 1.68514 11.0601C2.81581 12.325 4.38782 13.1091 6.07843 13.2514C7.76905 13.3937 9.44999 12.8834 10.7762 11.8252L14.7349 15.7839C14.8044 15.8527 14.8869 15.907 14.9774 15.9439C15.068 15.9808 15.165 15.9995 15.2628 15.9989C15.3606 15.9983 15.4573 15.9784 15.5475 15.9405C15.6376 15.9025 15.7194 15.8471 15.7881 15.7776C15.8568 15.708 15.9112 15.6256 15.9481 15.535C15.985 15.4444 16.0036 15.3474 16.0031 15.2496C16.0025 15.1518 15.9826 15.0551 15.9446 14.965C15.9067 14.8748 15.8513 14.7931 15.7817 14.7243V14.7328ZM6.63737 11.7913C5.61803 11.7913 4.62157 11.4891 3.77402 10.9228C2.92646 10.3564 2.26587 9.5515 1.87578 8.60975C1.4857 7.668 1.38363 6.63172 1.5825 5.63196C1.78136 4.6322 2.27222 3.71386 2.99301 2.99307C3.7138 2.27229 4.63214 1.78142 5.6319 1.58256C6.63166 1.38369 7.66793 1.48576 8.60969 1.87585C9.55144 2.26593 10.3564 2.92652 10.9227 3.77408C11.489 4.62163 11.7913 5.61809 11.7913 6.63743C11.7896 8.00382 11.2461 9.31376 10.2799 10.2799C9.3137 11.2461 8.00376 11.7897 6.63737 11.7913Z' fill='%23d4281c'/%3E%3C/svg%3E%0A");
|
||||
border: 1px solid $red;
|
||||
border-left: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue