Skip to content

Commit

Permalink
fix backend
Browse files Browse the repository at this point in the history
  • Loading branch information
TkachenkoKaterina committed Mar 15, 2024
1 parent 7f1cc43 commit 26a945f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/components/ContactForm/ContactForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const ContactForm = () => {
const contacts = useSelector(selectContacts);

const [name, setName] = useState('');
const [number, setNumber] = useState('');
const [phone, setPhone] = useState('');

const handleChange = e => {
if (e.target.name === 'name') {
setName(e.target.value);
} else if (e.target.name === 'number') {
setNumber(e.target.value);
} else if (e.target.name === 'phone') {
setPhone(e.target.value);
}
};

Expand All @@ -32,9 +32,9 @@ const ContactForm = () => {
if (isDuplicate) {
alert(`${name} is already in contacts!`);
} else {
dispatch(addContact({ id: nanoid(), name, number }));
dispatch(addContact({ id: nanoid(), name, phone }));
setName('');
setNumber('');
setPhone('');
}
};

Expand All @@ -54,14 +54,14 @@ const ContactForm = () => {
/>

<label className={css.label} htmlFor="tel">
Number
Phone
</label>
<input
className={css.input}
id="tel"
type="tel"
name="number"
value={number}
name="phone"
value={phone}
onChange={handleChange}
required
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ContactItem/ContactItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ContactItem = ({ contact, onDeleteContact }) => {

return (
<li className={css.li}>
{contact.name}: {contact.number}
{contact.name}: {contact.phone}
<button className={css.button} onClick={handleDeleteContact}>
Delete
</button>
Expand All @@ -21,7 +21,7 @@ ContactItem.propTypes = {
contact: PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
number: PropTypes.string,
phone: PropTypes.string,
}).isRequired,
onDeleteContact: PropTypes.func.isRequired,
};
Expand Down
1 change: 1 addition & 0 deletions src/components/ContactList/ContactList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { deleteContact, fetchContacts } from 'store/operations';
const ContactList = () => {
const dispatch = useDispatch();
const filteredContacts = useSelector(selectFilteredContacts);
console.log('filteredContacts :>> ', filteredContacts);

useEffect(() => {
dispatch(fetchContacts());
Expand Down

0 comments on commit 26a945f

Please sign in to comment.