mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 11:26:25 -05:00
VIN Numbers can be decoded.
This commit is contained in:
parent
e5fe1b6bb9
commit
f2a4eb930c
8 changed files with 195 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import {useContext, useEffect, useRef, useState} from "react";
|
||||
import {
|
||||
fetchDecoded,
|
||||
fetchDomains,
|
||||
fetchFilesProgress,
|
||||
filesSearch,
|
||||
|
|
@ -928,3 +929,29 @@ export const useUploadFile = () => {
|
|||
|
||||
return {files, setFiles: handleFilesChange, progresses, destination, setDestination, doClear, doUpload}
|
||||
}
|
||||
|
||||
export const useVINDecoder = (defaultVINNumber = '') => {
|
||||
const [value, setValue] = useState(defaultVINNumber);
|
||||
// The response vin from the API.
|
||||
const [vin, setVin] = useState(null);
|
||||
|
||||
const localFetchDecoded = async () => {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const vin = await fetchDecoded(value);
|
||||
setVin(vin);
|
||||
} catch (e) {
|
||||
console.error('Failed to decode VIN number');
|
||||
setVin(null);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
localFetchDecoded();
|
||||
}, [value]);
|
||||
|
||||
return {value, setValue, vin}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue