Skip to content

Commit

Permalink
use field.name instead of label
Browse files Browse the repository at this point in the history
  • Loading branch information
tokdaniel committed Nov 7, 2023
1 parent 35b7e1c commit 0f88644
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ const ProductEditor: FC = () => {

const onPersonalDataSelectionChange = (field: PersonalDataField) => {
const isFieldSelected =
selectedPersonalDataFields[
field.label.toLowerCase() as PersonalDataFieldType
];
selectedPersonalDataFields[field.name as PersonalDataFieldType];

const index = fields.findIndex(({ label }) => label === field.label);
const index = fields.findIndex(({ name }) => name === field.name);

isFieldSelected ? remove(index) : append(field);

setSelectedPersonalDataFields((prev) => ({
...prev,
[field.label.toLowerCase()]: !isFieldSelected,
[field.name]: !isFieldSelected,
}));
};

Expand Down Expand Up @@ -133,12 +131,12 @@ const ProductEditor: FC = () => {
<FormGroup>
{[EmailField, PhoneNumberField].map((field, i) => (
<FormControlLabel
key={`${field.label}-${i}`}
key={`${field.name}-${i}`}
control={
<Checkbox
value={
selectedPersonalDataFields[
field.label.toLowerCase() as PersonalDataFieldType
field.name as PersonalDataFieldType
]
}
onChange={() => onPersonalDataSelectionChange(field)}
Expand Down

0 comments on commit 0f88644

Please sign in to comment.