mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-09-07 14:15:45 +00:00
feat: refactor department to organization and move certifications to configuration tab commit
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { baseApi } from '@ema-platform/api';
|
||||
import type {
|
||||
Department,
|
||||
Organization,
|
||||
Profession,
|
||||
ListResponse,
|
||||
CreateProfessionPayload,
|
||||
@@ -9,8 +9,8 @@ import type {
|
||||
|
||||
const configurationApi = baseApi.injectEndpoints({
|
||||
endpoints: (builder) => ({
|
||||
getDepartments: builder.query<ListResponse<Department>, void>({
|
||||
query: () => '/departments',
|
||||
getOrganizations: builder.query<ListResponse<Organization>, void>({
|
||||
query: () => '/organizations',
|
||||
providesTags: ['Api'],
|
||||
}),
|
||||
|
||||
@@ -35,11 +35,11 @@ const configurationApi = baseApi.injectEndpoints({
|
||||
invalidatesTags: ['Api'],
|
||||
}),
|
||||
}),
|
||||
overrideExisting: false,
|
||||
overrideExisting: true,
|
||||
});
|
||||
|
||||
export const {
|
||||
useGetDepartmentsQuery,
|
||||
useGetOrganizationsQuery,
|
||||
useGetProfessionsQuery,
|
||||
useCreateProfessionMutation,
|
||||
useUpdateProfessionMutation,
|
||||
|
||||
@@ -19,12 +19,13 @@ import {
|
||||
} from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { useDisclosure } from '@mantine/hooks';
|
||||
import { IconEdit, IconTrash, IconPlus, IconBriefcase, IconMap, IconInfoCircle } from '@tabler/icons-react';
|
||||
import { IconEdit, IconTrash, IconPlus, IconBriefcase, IconMap, IconCertificate, IconInfoCircle } from '@tabler/icons-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { notify } from '@ema-platform/ui';
|
||||
import { LocationPage } from '../../location/pages/LocationPage';
|
||||
import { CertificationPage } from '../../certification/pages/CertificationPage';
|
||||
import {
|
||||
useGetDepartmentsQuery,
|
||||
useGetOrganizationsQuery,
|
||||
useGetProfessionsQuery,
|
||||
useCreateProfessionMutation,
|
||||
useUpdateProfessionMutation,
|
||||
@@ -129,13 +130,13 @@ function ProfessionForm({ editingProf, deptOptions, isSubmitting, onSubmit, onCa
|
||||
|
||||
function ProfessionTab() {
|
||||
const { t } = useTranslation();
|
||||
const { data: deptRes } = useGetDepartmentsQuery();
|
||||
const { data: deptRes } = useGetOrganizationsQuery();
|
||||
const { data: profRes, isLoading, isError } = useGetProfessionsQuery();
|
||||
const [createProfession, { isLoading: isCreating }] = useCreateProfessionMutation();
|
||||
const [updateProfession, { isLoading: isUpdating }] = useUpdateProfessionMutation();
|
||||
const [deleteProfession] = useDeleteProfessionMutation();
|
||||
|
||||
const departments = deptRes?.items ?? [];
|
||||
const departments = Array.isArray(deptRes) ? deptRes : (deptRes?.items ?? []);
|
||||
const professions = profRes?.items ?? [];
|
||||
|
||||
const [editingProf, setEditingProf] = useState<Profession | null>(null);
|
||||
@@ -143,9 +144,9 @@ function ProfessionTab() {
|
||||
const [deleteTarget, setDeleteTarget] = useState<Profession | null>(null);
|
||||
const [deleteOpened, { open: openDelete, close: closeDelete }] = useDisclosure(false);
|
||||
|
||||
const deptOptions = departments.filter((d) => d.isActive).map((d) => ({
|
||||
const deptOptions = departments.filter((d) => d?.status?.toLowerCase() === 'active').map((d) => ({
|
||||
value: d.id,
|
||||
label: d.name.en,
|
||||
label: d.name?.en ?? d.name ?? '',
|
||||
}));
|
||||
|
||||
const resetProfForm = useCallback(() => {
|
||||
@@ -312,6 +313,9 @@ export function ConfigurationPage() {
|
||||
<Tabs.Tab value="locations" leftSection={<IconMap size={16} />}>
|
||||
{t('location.title')}
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="certifications" leftSection={<IconCertificate size={16} />}>
|
||||
Certifications
|
||||
</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Tabs.Panel value="professions" pt="md">
|
||||
@@ -321,6 +325,10 @@ export function ConfigurationPage() {
|
||||
<Tabs.Panel value="locations" pt="md">
|
||||
<LocationPage />
|
||||
</Tabs.Panel>
|
||||
|
||||
<Tabs.Panel value="certifications" pt="md">
|
||||
<CertificationPage />
|
||||
</Tabs.Panel>
|
||||
</Tabs>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -3,11 +3,15 @@ export interface NamePair {
|
||||
am: string;
|
||||
}
|
||||
|
||||
export interface Department {
|
||||
export interface Organization {
|
||||
id: string;
|
||||
name: NamePair;
|
||||
description: NamePair;
|
||||
isActive: boolean;
|
||||
key: string;
|
||||
isSuperAdmin: boolean;
|
||||
isGovernmentOrganization: boolean;
|
||||
status: string;
|
||||
parentId: string | null;
|
||||
organizationTypeId: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -15,7 +19,7 @@ export interface Department {
|
||||
export interface Profession {
|
||||
id: string;
|
||||
departmentId: string;
|
||||
department?: Department;
|
||||
department?: Organization;
|
||||
name: NamePair;
|
||||
description: NamePair;
|
||||
isActive: boolean;
|
||||
|
||||
Reference in New Issue
Block a user