mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 23:46:18 -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,11 +1,11 @@
|
|||
import React, {useContext} from 'react';
|
||||
import {Divider, SegmentGroup, StatisticLabel, StatisticValue} from "semantic-ui-react";
|
||||
import {Divider, Input, SegmentGroup, StatisticLabel, StatisticValue, TableCell, TableRow} from "semantic-ui-react";
|
||||
import {Link, Route, Routes} from "react-router-dom";
|
||||
import {decryptOTP, encryptOTP} from "../api";
|
||||
import {humanFileSize, mimetypeColor, PageContainer, toLocaleString, useTitle} from "./Common";
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import {Button, Header, Loader, Segment, Statistic, StatisticGroup, TextArea} from "./Theme";
|
||||
import {useStatistics} from "../hooks/customHooks";
|
||||
import {Button, Header, Loader, Segment, Statistic, StatisticGroup, Table, TextArea} from "./Theme";
|
||||
import {useStatistics, useVINDecoder} from "../hooks/customHooks";
|
||||
|
||||
class Encrypt extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -145,6 +145,57 @@ function OTP() {
|
|||
</>
|
||||
}
|
||||
|
||||
function VINDecoder() {
|
||||
useTitle('VIN Number Decoder');
|
||||
const {t} = useContext(ThemeContext);
|
||||
|
||||
const basicKeys = ['Country', 'Manufacturer', 'Region', 'Years'];
|
||||
const detailsKeys = ['Body', 'Engine', 'Model', 'Plant', 'Transmission', 'Serial'];
|
||||
|
||||
const {value, setValue, vin} = useVINDecoder();
|
||||
console.debug(vin);
|
||||
|
||||
let body = <p {...t}>Enter a VIN number above</p>;
|
||||
if (value && !vin) {
|
||||
body = <p {...t}>VIN number is invalid</p>;
|
||||
}
|
||||
if (vin && vin['country']) {
|
||||
let details = <p {...t}>No details</p>;
|
||||
if (vin['body']) {
|
||||
details = <Table celled columns={2} {...t}>
|
||||
{detailsKeys.map(i => <TableRow key={i}>
|
||||
<TableCell width={5}><b>{i}</b></TableCell>
|
||||
<TableCell width={11}>{vin[i.toLowerCase()] || '(Unknown)'}</TableCell>
|
||||
</TableRow>)}
|
||||
</Table>;
|
||||
}
|
||||
body = <>
|
||||
<Table celled columns={2} {...t}>
|
||||
{basicKeys.map(i => <TableRow key={i}>
|
||||
<TableCell width={5}><b>{i}</b></TableCell>
|
||||
<TableCell width={11}>{vin[i.toLowerCase()]}</TableCell>
|
||||
</TableRow>)}
|
||||
</Table>
|
||||
<Header as='h3'>Details</Header>
|
||||
{details}
|
||||
</>;
|
||||
}
|
||||
|
||||
return <>
|
||||
<Header as='h1'>VIN Number Decoder</Header>
|
||||
<Input
|
||||
size='large'
|
||||
label='VIN'
|
||||
value={value}
|
||||
onChange={e => setValue(e.target.value)}
|
||||
/>
|
||||
|
||||
<Header as='h2'>Decoded</Header>
|
||||
{body}
|
||||
</>
|
||||
}
|
||||
|
||||
|
||||
function StatisticsPage() {
|
||||
useTitle('Statistics');
|
||||
|
||||
|
|
@ -251,6 +302,7 @@ export function MoreRoute(props) {
|
|||
<Routes>
|
||||
<Route path='otp' exact element={<OTP/>}/>
|
||||
<Route path='statistics' exact element={<StatisticsPage/>}/>
|
||||
<Route path='vin' exact element={<VINDecoder/>}/>
|
||||
</Routes>
|
||||
</PageContainer>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ const links = [
|
|||
links: [
|
||||
{to: '/more/otp', text: 'One Time Pad', end: true},
|
||||
{to: '/more/statistics', text: 'Statistics', end: true},
|
||||
{to: '/more/vin', text: 'VIN Decoder', end: true},
|
||||
]
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue