CEC-247, CEC-261 Manifest and ECU display (#65)
* CEC-261 Add ECU list control * CEC-261 Update vehicle service mock * CEC-247 Manifest screens * Fix test * Remove dynamic dates from mocks * Remove timezone from mock dates * Fix test for date string timezone difference
This commit is contained in:
34
src/components/Controls/ECUList/index.jsx
Normal file
34
src/components/Controls/ECUList/index.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { Chip } from "@material-ui/core";
|
||||
|
||||
const ECUList = ({ list, delimiter, search }) => {
|
||||
if (!list) return null;
|
||||
if (!delimiter) delimiter = ",";
|
||||
|
||||
const items = list.split(delimiter);
|
||||
|
||||
return items.map((item, index) => {
|
||||
const match = search
|
||||
? item.toLowerCase().split(" ").indexOf(search.toLowerCase())
|
||||
: -1;
|
||||
return (
|
||||
<Chip
|
||||
key={index}
|
||||
label={item}
|
||||
size="small"
|
||||
variant={match > -1 ? "default" : "outlined"}
|
||||
color={match > -1 ? "primary" : "default"}
|
||||
style={{ margin: 1 }}
|
||||
/>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
ECUList.propTypes = {
|
||||
list: PropTypes.string,
|
||||
delimiter: PropTypes.string,
|
||||
search: PropTypes.string,
|
||||
};
|
||||
|
||||
export default ECUList;
|
||||
Reference in New Issue
Block a user