Skip to content

Commit

Permalink
component UsersFilter accepts a user to be excluded (self)
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Sep 15, 2024
1 parent 1923593 commit ed0cb2c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/src/components/UsersFilter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useEffect, useState } from "react";
import toastError from "../../errors/toastError";
import api from "../../services/api";

export function UsersFilter({ onFiltered, initialUsers }) {
export function UsersFilter({ onFiltered, initialUsers, excludeId }) {
const [users, setUsers] = useState([]);
const [selecteds, setSelecteds] = useState([]);

Expand All @@ -30,7 +30,10 @@ export function UsersFilter({ onFiltered, initialUsers }) {
const loadUsers = async () => {
try {
const { data } = await api.get(`/users/list`);
const userList = data.map((u) => ({ id: u.id, name: u.name }));
let userList = data.map((u) => ({ id: u.id, name: u.name }));
if (excludeId) {
userList = userList.filter(user => user.id !== excludeId);
}
setUsers(userList);
} catch (err) {
toastError(err);
Expand Down

0 comments on commit ed0cb2c

Please sign in to comment.