CEC-4241 - Add trouble code to DTC search (#356)

This commit is contained in:
Paul Adamsen
2023-06-13 15:54:04 -04:00
committed by GitHub
parent 99e2058ffd
commit a68c00b4ad
4 changed files with 59 additions and 6 deletions

View File

@@ -9,15 +9,15 @@ export const DTCTimelineProvider = ({ children }) => {
const [dtcData, setDTCData] = useState([]);
const [total, setTotal] = useState(0)
const getDTCData = async (vin, ecu, startDate, endDate, search,token) => {
const getDTCData = async (vin, ecu, troubleCode, startDate, endDate, search, token) => {
try {
setBusy(true);
const result = await api.getDTCData(vin, ecu, startDate, endDate, search,token);
const result = await api.getDTCData(vin, ecu, troubleCode, startDate, endDate, search, token);
if (result.error) {
throw new Error(`Get DTC data error. ${result.message}`);
}
setDTCData(result.data ?? []);
if (result.total){
if (result.total) {
setTotal(result.total)
}
return result;

View File

@@ -377,6 +377,42 @@ exports[`Render Render 1`] = `
</fieldset>
</div>
</div>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-marginNormal MuiFormControl-fullWidth"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined"
data-shrink="true"
for="trouble_code_field"
id="trouble_code_field-label"
>
Trouble Code
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-fullWidth MuiInputBase-formControl"
>
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
id="trouble_code_field"
name="trouble_code_field"
type="text"
value=""
/>
<fieldset
aria-hidden="true"
class="PrivateNotchedOutline-root-0 MuiOutlinedInput-notchedOutline"
>
<legend
class="PrivateNotchedOutline-legendLabelled-0 PrivateNotchedOutline-legendNotched-0"
>
<span>
Trouble Code
</span>
</legend>
</fieldset>
</div>
</div>
</div>
</div>
<div

View File

@@ -23,6 +23,7 @@ const MainForm = ({ vin }) => {
const [selectedStartDate, setSelectedStartDate] = useState(new Date(Date.now() - 24 * 60 * 60 * 1000));
const [selectedEndDate, setSelectedEndDate] = useState(new Date());
const [selectedECU, setSelectedECU] = useState("");
const [selectedTroubleCode, setSelectedTroubleCode] = useState("");
const [gmtTimezone, setGmtTimezone] = useState(false);
const [loading, setLoading] = useState(false);
const { setMessage } = useStatusContext();
@@ -101,7 +102,7 @@ const MainForm = ({ vin }) => {
offset: pageSize * pageIndex,
order: `${orderBy} ${order}`,
}
await getDTCData(vin, selectedECU, start_date, end_date, search, token);
await getDTCData(vin, selectedECU, selectedTroubleCode, start_date, end_date, search, token);
// setDTCData(data);
} catch (e) {
setMessage(e.message);
@@ -244,6 +245,21 @@ const MainForm = ({ vin }) => {
setSelectedECU(e.target.value);
}}
/>
<TextField
id="trouble_code_field"
name="trouble_code_field"
label="Trouble Code"
InputLabelProps={{
shrink: true
}}
defaultValue=""
variant="outlined"
margin="normal"
fullWidth
onChange={(e) => {
setSelectedTroubleCode(e.target.value);
}}
/>
</div>
</Grid>
<Grid item xs={12}>