Closed shpomp closed 3 years ago
@shpomp How is the owner added here?
@shpomp How is the owner added here?
The owner is used as the initial state of the members array, that Diny uses to loop through with the addMember endpoint:
// ...
import { useUser } from '../../firebase/UserContext';
export default function CreateBoard() {
const { user } = useUser();
const userId = user[0].id;
const [members, setMembers] = useState([userId]);
const addMember = (id) => {
setMembers([...members, id]);
};
// ....
The owner (user) is also hidden from the UI now, which is more logical:
// ...
const renderUser = (user) => {
if (user.id !== userId) {
// ....
So the members array is now always starting with members[0] = owner, where endpoint takes care of this, as userId === memberId
Description
AddMembers page now hides the user from UI when adding members, but is designed in a way to add it automatically as the 'owner' type of member to the board.
Fixes #250
npm run dev and check http://localhost:3000/boards/new-board - add member
Checklist