Skip to content

Commit

Permalink
Merge pull request #205 from FINTLabs/FKS-1066-frontend-paginering-pa…
Browse files Browse the repository at this point in the history
…-ressurser-under-bruker-ny-tildeling

Added resourcefilter on assignment for user
  • Loading branch information
Linda-fintlabs authored Jan 15, 2025
2 parents 9052994 + 543c66b commit 97d1227
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
14 changes: 13 additions & 1 deletion app/components/app-bar/AppBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MeInfo from "~/components/app-bar/MeInfo";
import {IMeInfo} from "~/data/types";
import {BodyShort, Hide, HStack} from "@navikt/ds-react";
import {BodyShort, Button, Hide, HStack} from "@navikt/ds-react";
import {Link} from "@remix-run/react";
import {Menu} from "~/components/app-bar/Menu";

Expand Down Expand Up @@ -32,7 +32,19 @@ export function AppBar(props: { me: IMeInfo, basePath?: string, source?: string
:
null
}
{/*<Button variant="primary"
as={Link}
to="/_oauth/logout">
Logg ut
</Button>
<Button variant="primary"
as="a"
href={`${props.basePath}/_oauth/logout`}>
Logg ut
</Button>
*/}
</HStack>
</div>
</HStack>
Expand Down
1 change: 0 additions & 1 deletion app/components/user/AssignResourceToUserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const AssignResourceToUserTable = ({
icon={<PlusIcon/>}
iconPosition="right"
href={`${basePath}${getConfirmUserAssignmentUrl(Number(userId), resource.id, orgId)}${prepareQueryParams(searchParams)}`}
// href={`${basePath}/assignment/user/${userId}/orgunit/resource/${resource.id}/assign${prepareQueryParams(searchParams)}`}
underline={false}
>
Tildel
Expand Down
4 changes: 2 additions & 2 deletions app/data/fetch-assignments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const fetchAssignedUsers = async (request: Request, id: string | undefine

}

export const fetchAssignedResourcesUser = async (request: Request, id: string | undefined, size: string, page: string) => {
const response = await fetch(`${ASSIGNMENT_API_URL}${BASE_PATH}/api/assignments/v2/user/${id}/resources?size=${size}&page=${page}`,
export const fetchAssignedResourcesUser = async (request: Request, id: string | undefined, size: string, page: string, resourceType: string, resourceFilter: string) => {
const response = await fetch(`${ASSIGNMENT_API_URL}${BASE_PATH}/api/assignments/v2/user/${id}/resources?size=${size}&page=${page}&resourceType=${resourceType}${resourceFilter}`,
{
headers: request.headers
});
Expand Down
17 changes: 11 additions & 6 deletions app/routes/bruker.$id.org.$orgId.ny-tildeling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,23 @@ export async function loader({params, request}: LoaderFunctionArgs): Promise<Omi
const applicationcategory = url.searchParams.get("applicationcategory") ?? "";
const accessType = url.searchParams.get("accesstype") ?? "";

const resourceResponse = await fetchResources(request, size, page, search, orgUnits, applicationcategory, accessType)
const resourceList: IResourceList = await resourceResponse.json()

const [responseResources, responseOrgUnits, responseAssignments, responseUser, responseApplicationCategories] = await Promise.all([
fetchResources(request, size, page, search, orgUnits, applicationcategory, accessType),
let filter = ""
resourceList.resources.forEach(value => {
filter += `&resourcefilter=${value.id}`

})

const [responseOrgUnits, responseAssignments, responseUser, responseApplicationCategories] = await Promise.all([
fetchOrgUnits(request),
fetchAssignedResourcesUser(request, params.id, "1000", "0"),
fetchAssignedResourcesUser(request, params.id, size, "0", "ALLTYPES", filter),
fetchUserById(request, params.id),
fetchApplicationCategory(request),
// fetchAccessType(request)


]);
const resourceList: IResourceList = await responseResources.json()

const orgUnitTree: IUnitTree = await responseOrgUnits.json()
const orgUnitList: IUnitItem[] = orgUnitTree.orgUnits
const assignedResourceList: IAssignedResourcesList = await responseAssignments.json()
Expand Down

0 comments on commit 97d1227

Please sign in to comment.