diff --git a/src/components/items/ItemAssign.jsx b/src/components/items/ItemAssign.jsx new file mode 100644 index 0000000..809b92f --- /dev/null +++ b/src/components/items/ItemAssign.jsx @@ -0,0 +1,34 @@ +import { store } from '../../store/billStore.js'; + +export function ItemAssign({ item }) { + const assignedTo = store.getAssignedPeople(item.id); + + const togglePerson = (personId) => { + const current = assignedTo.includes(personId) + ? assignedTo.filter(id => id !== personId) + : [...assignedTo, personId]; + store.setAssignment(item.id, current); + }; + + const people = store.people.value; + + if (people.length === 0) { + return

Add people first to assign items

; + } + + return ( +
+ Split between: + {people.map((person) => ( + + ))} +
+ ); +}