CEC-4241 - Add trouble code to DTC search (#356)
This commit is contained in:
@@ -9,15 +9,15 @@ export const DTCTimelineProvider = ({ children }) => {
|
|||||||
const [dtcData, setDTCData] = useState([]);
|
const [dtcData, setDTCData] = useState([]);
|
||||||
const [total, setTotal] = useState(0)
|
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 {
|
try {
|
||||||
setBusy(true);
|
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) {
|
if (result.error) {
|
||||||
throw new Error(`Get DTC data error. ${result.message}`);
|
throw new Error(`Get DTC data error. ${result.message}`);
|
||||||
}
|
}
|
||||||
setDTCData(result.data ?? []);
|
setDTCData(result.data ?? []);
|
||||||
if (result.total){
|
if (result.total) {
|
||||||
setTotal(result.total)
|
setTotal(result.total)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -377,6 +377,42 @@ exports[`Render Render 1`] = `
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const MainForm = ({ vin }) => {
|
|||||||
const [selectedStartDate, setSelectedStartDate] = useState(new Date(Date.now() - 24 * 60 * 60 * 1000));
|
const [selectedStartDate, setSelectedStartDate] = useState(new Date(Date.now() - 24 * 60 * 60 * 1000));
|
||||||
const [selectedEndDate, setSelectedEndDate] = useState(new Date());
|
const [selectedEndDate, setSelectedEndDate] = useState(new Date());
|
||||||
const [selectedECU, setSelectedECU] = useState("");
|
const [selectedECU, setSelectedECU] = useState("");
|
||||||
|
const [selectedTroubleCode, setSelectedTroubleCode] = useState("");
|
||||||
const [gmtTimezone, setGmtTimezone] = useState(false);
|
const [gmtTimezone, setGmtTimezone] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const { setMessage } = useStatusContext();
|
const { setMessage } = useStatusContext();
|
||||||
@@ -101,7 +102,7 @@ const MainForm = ({ vin }) => {
|
|||||||
offset: pageSize * pageIndex,
|
offset: pageSize * pageIndex,
|
||||||
order: `${orderBy} ${order}`,
|
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);
|
// setDTCData(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMessage(e.message);
|
setMessage(e.message);
|
||||||
@@ -244,6 +245,21 @@ const MainForm = ({ vin }) => {
|
|||||||
setSelectedECU(e.target.value);
|
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>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ import {
|
|||||||
const API_ENDPOINT = process.env.REACT_APP_OTA_SERVICE_URL;
|
const API_ENDPOINT = process.env.REACT_APP_OTA_SERVICE_URL;
|
||||||
|
|
||||||
const DTCTimelineAPI = {
|
const DTCTimelineAPI = {
|
||||||
getDTCData: async (vin, ecu, startDate, endDate,search,token) => {
|
getDTCData: async (vin, ecu, troubleCode, startDate, endDate, search, token) => {
|
||||||
const queryParams = {
|
const queryParams = {
|
||||||
ecu,
|
ecu,
|
||||||
|
trouble_code: troubleCode,
|
||||||
start_time: startDate,
|
start_time: startDate,
|
||||||
end_time: endDate,
|
end_time: endDate,
|
||||||
decode:true,
|
decode: true,
|
||||||
...search,
|
...search,
|
||||||
};
|
};
|
||||||
const url = addQueryParams(`${API_ENDPOINT}/dtcs/${vin}`, queryParams);
|
const url = addQueryParams(`${API_ENDPOINT}/dtcs/${vin}`, queryParams);
|
||||||
|
|||||||
Reference in New Issue
Block a user