Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize new route for admin to just collect 1 site #232

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DeploymentSteps.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Don't delete old sections - just leave them towards the bottom of the file, and

## Next (pending changes for the next coming release)

## 0.8.0

1. Admin must be deployed before the portal to include the Role changes needed for setting client types (sas-UID2-1782-approved-types-to-admin)
2. Admin must be deployed before the portal to include the Get Site By Id endpoint utilized (jss-UID2-2065-get-site-by-id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to move these down, since admin is already deployed.


## 0.7.5

Expand Down
10 changes: 7 additions & 3 deletions src/api/routers/usersRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserRole } from '../entities/User';
import { getLoggers, getTraceId } from '../helpers/loggingHelpers';
import { mapClientTypeToParticipantType } from '../helpers/siteConvertingHelpers';
import { getKcAdminClient } from '../keycloakAdminClient';
import { getSiteList } from '../services/adminServiceClient';
import { getSite, getSiteList } from '../services/adminServiceClient';
import {
assignClientRoleToUser,
deleteUserByEmail,
Expand Down Expand Up @@ -58,8 +58,12 @@ export function createUsersRouter() {

usersRouter.get('/current/participant', async (req: UserRequest, res) => {
const currentParticipant = await Participant.query().findOne({ id: req.user!.participantId });
const sites = await getSiteList();
const currentSite = sites.find((x) => x.id === currentParticipant?.siteId);

const currentSite =
currentParticipant?.siteId === undefined
? undefined
: await getSite(currentParticipant?.siteId);

const allParticipantTypes = await ParticipantType.query();
const result = {
...currentParticipant,
Expand Down
5 changes: 5 additions & 0 deletions src/api/services/adminServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export const getSiteList = async (): Promise<SiteDTO[]> => {
return response.data;
};

export const getSite = async (siteId: number): Promise<SiteDTO> => {
const response = await adminServiceClient.get<SiteDTO>(`/api/site/${siteId}`);
return response.data;
};

export const getVisibleSiteList = async (): Promise<SiteDTO[]> => {
const siteList = await getSiteList();
return siteList.filter((x) => x.visible !== false);
Expand Down