Skip to content

Commit

Permalink
fix(OH2-402): Fix select filters in administration section (#674)
Browse files Browse the repository at this point in the history
Co-authored-by: SteveGT96 <[email protected]>
  • Loading branch information
SteveGT96 and SteveGT96 authored Oct 8, 2024
1 parent 43bf482 commit f9be3b1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ExamsTable = ({ onDelete, onEdit, headerActions }: IOwnProps) => {

const filters: TFilterField[] = [
{
key: "type",
key: "examtype",
label: t("exam.examtype"),
type: "select",
options: examTypesOptions,
Expand Down Expand Up @@ -124,7 +124,10 @@ export const ExamsTable = ({ onDelete, onEdit, headerActions }: IOwnProps) => {
onDelete={onDelete}
headerActions={headerActions}
filterColumns={filters}
rawData={data ?? []}
rawData={(data ?? []).map((exam) => ({
...exam,
examtype: exam.examtype?.code,
}))}
manualFilter={false}
rowKey="code"
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/accessories/admin/operations/Operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useAppDispatch } from "libraries/hooks/redux";
import React, { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router";
import { getOperationTypes } from "state/types/operations";
import { PATHS } from "../../../../consts";
import { OperationDTO } from "../../../../generated";
import {
Expand All @@ -20,6 +21,7 @@ export const Operations = () => {

useEffect(() => {
dispatch(getOperations());
dispatch(getOperationTypes());

return () => {
dispatch(deleteOperationReset());
Expand Down
20 changes: 19 additions & 1 deletion src/components/accessories/admin/users/usersTable/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import InfoBox from "../../../infoBox/InfoBox";
import Table from "../../../table/Table";
import { TFilterField } from "../../../table/filter/types";

import { getUserGroups } from "state/usergroups";
import classes from "./UsersTable.module.scss";

interface IOwnProps {
Expand All @@ -21,6 +22,7 @@ export const UsersTable = ({ headerActions }: IOwnProps) => {

useEffect(() => {
dispatch(getUsers({}));
dispatch(getUserGroups());
}, [dispatch]);

const header = ["userName", "userGroupName", "desc"];
Expand All @@ -31,8 +33,21 @@ export const UsersTable = ({ headerActions }: IOwnProps) => {
desc: t("user.description"),
};
const order = ["userName", "userGroupName", "desc"];
const userGroupOptions = useAppSelector(
(state) =>
state.usergroups.groupList.data?.map((item) => ({
value: item.code ?? "",
label: item.desc ?? item.code ?? "",
})) ?? []
);

const filters: TFilterField[] = [
{
key: "userGroupName",
label: t("user.groups"),
type: "select",
options: userGroupOptions,
},
{ key: "userName", label: t("user.username"), type: "text" },
];

Expand Down Expand Up @@ -75,7 +90,10 @@ export const UsersTable = ({ headerActions }: IOwnProps) => {
filterColumns={filters}
manualFilter={false}
isCollapsabile={false}
rawData={data}
rawData={(data ?? []).map((user) => ({
...user,
userGroupName: user.userGroupName?.code,
}))}
rowKey="userName"
headerActions={headerActions}
/>
Expand Down

0 comments on commit f9be3b1

Please sign in to comment.