Skip to content

Commit

Permalink
Fix data type conversion issue in SimilarSerachfield component (#166)
Browse files Browse the repository at this point in the history
BigInt are not support in MuiChipsInput
  • Loading branch information
kartik-gupta-ij authored Mar 10, 2024
1 parent de1284a commit c710f9f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/components/Points/SimilarSerachfield.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ import { MuiChipsInput } from 'mui-chips-input';

function SimilarSerachfield({ value, setValue }) {
const handleChange = (newChips) => {
const isnum = /^\d+$/.test(newChips);
const result = newChips.map(function (x) {
if (!isnum) {
return x;
const newValue = newChips.map(function (val) {
if (Number.isInteger(parseInt(val, 10))) {
return BigInt(val);
} else {
return val;
}
return parseInt(x, 10);
});
setValue(result);
setValue(newValue);
};

return (
<Card sx={{ p: 2 }} variant="dual">
<MuiChipsInput fullWidth value={value} onChange={handleChange} placeholder={'Find Similar by ID'} />
<MuiChipsInput
fullWidth
value={value.map(function (x) {
return x.toString();
})}
onChange={handleChange}
placeholder={'Find Similar by ID'}
/>
</Card>
);
}
Expand Down

0 comments on commit c710f9f

Please sign in to comment.