diff --git a/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx b/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx index 5f95c9ac22adc9dd072984dc82749805ff114ae7..3887053892dda1e0ff1344fbb2705fb8662cf58b 100644 --- a/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx +++ b/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx @@ -10,7 +10,6 @@ import { apiPath } from '@/redux/apiPath'; import { HttpStatusCode } from 'axios'; import { loginFixture } from '@/models/fixtures/loginFixture'; import { overlaysFixture } from '@/models/fixtures/overlaysFixture'; -import { userPrivilegesFixture } from '@/models/fixtures/userPrivilegesFixture'; import { MODAL_INITIAL_STATE_MOCK } from '@/redux/modal/modal.mock'; import { userFixture } from '@/models/fixtures/userFixture'; import { LoginModal } from './LoginModal.component'; @@ -180,9 +179,7 @@ describe('LoginModal - component', () => { }); it('should close modal after successful login as user', async () => { mockedAxiosClient.onPost(apiPath.postLogin()).reply(HttpStatusCode.Ok, loginFixture); - mockedAxiosClient - .onGet(apiPath.userPrivileges(loginFixture.login)) - .reply(HttpStatusCode.Ok, userPrivilegesFixture); + mockedAxiosClient.onGet(apiPath.user(loginFixture.login)).reply(HttpStatusCode.Ok, userFixture); mockedAxiosClient .onGet( apiPath.getAllUserOverlaysByCreatorQuery({ diff --git a/src/models/fixtures/userPrivilegesFixture.ts b/src/models/fixtures/userPrivilegesFixture.ts deleted file mode 100644 index fcddc70ca1ea84b9a495a447d8760f6606529c8d..0000000000000000000000000000000000000000 --- a/src/models/fixtures/userPrivilegesFixture.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ZOD_SEED } from '@/constants'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { createFixture } from 'zod-fixture'; -import { userPrivilegesSchema } from '../userPrivilegesSchema'; - -export const userPrivilegesFixture = createFixture(userPrivilegesSchema, { - seed: ZOD_SEED, - array: { min: 2, max: 2 }, -}); diff --git a/src/models/userPrivilegesSchema.ts b/src/models/userPrivilegesSchema.ts index f6beb466003f69243f3e3537f22b326672d68ff3..06a491461d1e4d5f2463ab5b0b13e664064b0510 100644 --- a/src/models/userPrivilegesSchema.ts +++ b/src/models/userPrivilegesSchema.ts @@ -4,7 +4,3 @@ export const userPrivilegeSchema = z.object({ privilegeType: z.string(), objectId: z.string().nullable(), }); - -export const userPrivilegesSchema = z.object({ - privileges: z.array(userPrivilegeSchema), -}); diff --git a/src/redux/apiPath.ts b/src/redux/apiPath.ts index a24bc240037b12bdf87c91af7ea5777bd90e50f4..7a46759fe3af96f4d52bf63b0f60d02a93990304 100644 --- a/src/redux/apiPath.ts +++ b/src/redux/apiPath.ts @@ -93,6 +93,5 @@ export const apiPath = { getAllPlugins: (): string => `/plugins/`, getSubmapConnections: (): string => `projects/${PROJECT_ID}/submapConnections/`, logout: (): string => `doLogout`, - userPrivileges: (login: string): string => `users/${login}?columns=privileges`, user: (login: string): string => `users/${login}`, }; diff --git a/src/redux/user/user.reducers.test.ts b/src/redux/user/user.reducers.test.ts index 43cb814f22782d93971958c106f02c2623e01804..3033a51affb22201af934a6d97121115644077b9 100644 --- a/src/redux/user/user.reducers.test.ts +++ b/src/redux/user/user.reducers.test.ts @@ -8,7 +8,6 @@ import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; import { HttpStatusCode } from 'axios'; import { loginFixture } from '@/models/fixtures/loginFixture'; import { sessionFixture } from '@/models/fixtures/sessionFixture'; -import { userPrivilegesFixture } from '@/models/fixtures/userPrivilegesFixture'; import { userFixture } from '@/models/fixtures/userFixture'; import { apiPath } from '../apiPath'; import userReducer from './user.slice'; @@ -71,8 +70,8 @@ describe('user reducer', () => { it('should update store after successful getSessionValid query', async () => { mockedAxiosClient.onGet(apiPath.getSessionValid()).reply(HttpStatusCode.Ok, sessionFixture); mockedAxiosClient - .onGet(apiPath.userPrivileges(sessionFixture.login)) - .reply(HttpStatusCode.Ok, userPrivilegesFixture); + .onGet(apiPath.user(sessionFixture.login)) + .reply(HttpStatusCode.Ok, userFixture); mockedAxiosClient .onGet(apiPath.user(sessionFixture.login)) diff --git a/src/redux/user/user.utils.ts b/src/redux/user/user.utils.ts index 89a7afb8ae7e651dd682d7b9d0c2ff15c1cf8c87..ecb9c6239006f351b806b4fbf32d7bcf5cacd652 100644 --- a/src/redux/user/user.utils.ts +++ b/src/redux/user/user.utils.ts @@ -1,8 +1,5 @@ -import { UserPrivileges } from '@/types/models'; +import { UserPrivilege } from '@/types/models'; -export const hasPrivilege = ( - privileges: UserPrivileges['privileges'], - privilegeType: string, -): boolean => { +export const hasPrivilege = (privileges: UserPrivilege[], privilegeType: string): boolean => { return privileges.some(privilege => privilege.privilegeType === privilegeType); }; diff --git a/src/types/models.ts b/src/types/models.ts index ff160b0decf20db837223b5db3941715775c34d0..0b6b9373fba007b8b5c59968aed7716ca551329b 100644 --- a/src/types/models.ts +++ b/src/types/models.ts @@ -59,7 +59,7 @@ import { submapConnection } from '@/models/submapConnection'; import { targetElementSchema } from '@/models/targetElementSchema'; import { targetSchema } from '@/models/targetSchema'; import { targetSearchNameResult } from '@/models/targetSearchNameResult'; -import { userPrivilegeSchema, userPrivilegesSchema } from '@/models/userPrivilegesSchema'; +import { userPrivilegeSchema } from '@/models/userPrivilegesSchema'; import { z } from 'zod'; import { userSchema } from '@/models/userSchema'; @@ -112,7 +112,6 @@ export type GeneVariant = z.infer<typeof geneVariant>; export type TargetSearchNameResult = z.infer<typeof targetSearchNameResult>; export type TargetElement = z.infer<typeof targetElementSchema>; export type SubmapConnection = z.infer<typeof submapConnection>; -export type UserPrivileges = z.infer<typeof userPrivilegesSchema>; export type UserPrivilege = z.infer<typeof userPrivilegeSchema>; export type User = z.infer<typeof userSchema>; export type MarkerType = z.infer<typeof markerTypeSchema>;