Skip to content

Commit

Permalink
fix for showing all members
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Aug 15, 2024
1 parent 61fe2b7 commit 8d1f8b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const NetworkMembersTable = ({ nwid, central = false, organizationId }: I
() => networkById?.members ?? [],
[networkById?.members],
);
// const memoizedFakeMembers = useMemo(() => makeNetworkMemberData(100) ?? [], []);

// Save to localStorage whenever sorting changes
useEffect(() => {
Expand All @@ -74,7 +75,6 @@ export const NetworkMembersTable = ({ nwid, central = false, organizationId }: I
setData(memoizedMembers);
}, [memoizedMembers]);

// const [data, setData] = useState(() => makeNetworkMemberData(11));
const [data, setData] = useState(networkById?.members ?? []);
const columnsHeader = MemberHeaderColumns({ nwid, central, organizationId });
const defaultColumn = MemberEditCell({ nwid, central, organizationId });
Expand Down
7 changes: 4 additions & 3 deletions src/components/shared/tableFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ const MIN_COUNT_TO_SHOW_FOOTER = 11;

// biome-ignore lint/suspicious/noExplicitAny: <explanation>
const TableFooter = ({ table, page }: { table: Table<any>; page: string }) => {
const t = useTranslations("commonTable"); // use the 'footer' namespace
const t = useTranslations("commonTable");
const [pageSize, setPageSize] = useState<string | number>(
table.getState().pagination.pageSize,
);

const totalMembersCount = table?.options?.data?.length || 0;

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
Expand All @@ -52,10 +53,10 @@ const TableFooter = ({ table, page }: { table: Table<any>; page: string }) => {
setPageSize(savedPageSize || 10);
if (savedPageSize !== null) {
table.setPageSize(
savedPageSize === "all" ? table?.options?.data?.length : Number(savedPageSize),
savedPageSize === "all" ? totalMembersCount : Number(savedPageSize),
);
}
}, []);
}, [totalMembersCount]);

const storeLocalState = (pageSize) => {
table.setPageSize(pageSize === "all" ? totalMembersCount : Number(pageSize));
Expand Down
5 changes: 5 additions & 0 deletions src/utils/fakeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ const newMembers = (): Partial<MemberEntity> => {
return {
nwid: faker.string.uuid(),
id: faker.string.hexadecimal({ length: 10 }).substring(2),
creationTime: faker.date.past().getTime(),
lastSeen: faker.date.recent().toISOString(),
// online: faker.datatype.boolean(),
name: faker.person.firstName(),
authenticationExpiryTime: faker.date.future().getTime(),
lastAuthorizedTime: faker.date.recent().getTime(),
lastDeauthorizedTime: faker.date.recent().getTime(),
// age: faker.datatype.number(40),
// visits: faker.datatype.number(1000),
// progress: faker.datatype.number(100),
Expand Down

0 comments on commit 8d1f8b9

Please sign in to comment.