Skip to content

Commit

Permalink
fix(congregation): hide non-publisher when adding group members
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Dec 20, 2024
1 parent 2554da6 commit 600b870
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ const useGroupMembers = ({ group, onChange }: GroupMembersProps) => {
const [members, setMembers] = useState<MemberType[]>([]);
const [inputValue, setInputValue] = useState('');

const publishers_all = useMemo(() => {
return persons.filter(
(record) =>
record.person_data.publisher_baptized.active.value ||
record.person_data.publisher_unbaptized.active.value
);
}, [persons]);

const other_groups_members = useMemo(() => {
const otherGroups = groups.filter(
(record) => record.group_id !== group?.group_id
Expand Down Expand Up @@ -46,7 +54,7 @@ const useGroupMembers = ({ group, onChange }: GroupMembersProps) => {
const publishers_unassigned = useMemo(() => {
const assigned = [...other_groups_members, ...groups_members, ...overseers];

const result = persons.filter(
const result = publishers_all.filter(
(person) =>
assigned.some((record) => record.person_uid === person.person_uid) ===
false
Expand All @@ -66,8 +74,8 @@ const useGroupMembers = ({ group, onChange }: GroupMembersProps) => {
fullnameOption,
other_groups_members,
groups_members,
persons,
overseers,
publishers_all,
]);

const getIndex = () => {
Expand Down

0 comments on commit 600b870

Please sign in to comment.