Skip to content

Commit

Permalink
UPDATE: table
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremiahUy committed Jul 10, 2024
1 parent e38e05c commit f3267f4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
59 changes: 32 additions & 27 deletions apps/frontend/src/components/DpProcess/DpProcessTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import RouteLink from '../common/RouteLink'
import { useEffect, useState } from 'react'
import { getResourceById } from '../../api'
import { StyledLink } from 'baseui/link'
import { Tag } from '@navikt/ds-react'

type DpProcessTableProps = {
dpProcesses: DpProcess[]
Expand All @@ -17,6 +18,8 @@ const DpProcessTable = (props: DpProcessTableProps) => {
initialSortColumn: 'name',
})

const today = new Date().toISOString().split('T')[0]

useEffect(() => {
;(async () => {
if (props.dpProcesses) {
Expand All @@ -43,38 +46,40 @@ const DpProcessTable = (props: DpProcessTableProps) => {
return (
<>
<Table
emptyText='Ingen behandlinger'
emptyText="Ingen behandlinger"
headers={
<>
<HeadCell title='Behandling' column="name" tableState={[table, sortColumn]} />
<HeadCell title='Nummer' column="dpProcessNumber" tableState={[table, sortColumn]} />
<HeadCell title='Behandlingsansvarlig' column="externalProcessResponsible" tableState={[table, sortColumn]} />
<HeadCell title='Sist endret av' column="lastModifiedEmail" tableState={[table, sortColumn]} />
<HeadCell title="Behandling" column="name" tableState={[table, sortColumn]} />
<HeadCell title="Status" />
<HeadCell title="Behandlingsansvarlig" column="externalProcessResponsible" tableState={[table, sortColumn]} />
<HeadCell title="Sist endret av" column="lastModifiedEmail" tableState={[table, sortColumn]} />
</>
}
>
{table.data.map((process, index) => (
<Row key={index}>
<Cell>
<RouteLink href={`/dpprocess/${process.id}`} style={{ textDecoration: 'none' }}>
{process.name}
</RouteLink>
</Cell>
<Cell>
<div>
D{process.dpProcessNumber}
</div>
</Cell>
<Cell>
<RouteLink href={`/thirdparty/${process.externalProcessResponsible?.code}`} style={{ textDecoration: 'none' }}>
{process.externalProcessResponsible?.shortName}
</RouteLink>
</Cell>
<Cell>
<StyledLink href={'mailto: ' + process.lastModifiedEmail}>{process.lastModifiedEmail}</StyledLink>
</Cell>
</Row>
))}
{table.data.map((process, index) => {
const isActive = today < process.end

return (
<Row key={index}>
<Cell>
<RouteLink href={`/dpprocess/${process.id}`} style={{ textDecoration: 'none' }}>
{process.name}
</RouteLink>
</Cell>
<Cell>
<Tag variant={isActive ? 'success' : 'warning'}>{isActive ? 'Aktiv' : 'Utgått'}</Tag>
</Cell>
<Cell>
<RouteLink href={`/thirdparty/${process.externalProcessResponsible?.code}`} style={{ textDecoration: 'none' }}>
{process.externalProcessResponsible?.shortName}
</RouteLink>
</Cell>
<Cell>
<StyledLink href={'mailto: ' + process.lastModifiedEmail}>{process.lastModifiedEmail}</StyledLink>
</Cell>
</Row>
)
})}
</Table>
</>
)
Expand Down
1 change: 0 additions & 1 deletion apps/frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ export const processSort: ColumnCompares<Process> = {

export const dpProcessSort: ColumnCompares<DpProcess> = {
name: (a, b) => a.name.localeCompare(b.name),
dpProcessNumber: (a, b) => a.dpProcessNumber - b.dpProcessNumber,
externalProcessResponsible: (a, b) => (a.externalProcessResponsible?.shortName || '').localeCompare(b.externalProcessResponsible?.shortName || ''),
affiliation: (a, b) => (a.affiliation.department?.shortName || '').localeCompare(a.affiliation.department?.shortName || ''),
description: (a, b) => (a.description || '').localeCompare(b.description || ''),
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/pages/DpProcessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { HeadingMedium } from 'baseui/typography'
import { user } from '../service/User'
import { useNavigate } from 'react-router-dom'
import { Spinner } from 'baseui/spinner'
import {ampli} from "../service/Amplitude";
import {ampli} from '../service/Amplitude'

const DpProcessPage = () => {
const [showModal, toggleModal] = useReducer((prevState) => !prevState, false)
Expand All @@ -21,7 +21,7 @@ const DpProcessPage = () => {
const [isLoading, setLoading] = useState<boolean>(true)
const navigate = useNavigate()

ampli.logEvent("besøk", {side: 'NAV som databehandler', url: '/dpprocess', app: 'Behandlingskatalogen'})
ampli.logEvent('besøk', {side: 'NAV som databehandler', url: '/dpprocess', app: 'Behandlingskatalogen'})

useEffect(() => {
;(async () => {
Expand All @@ -43,7 +43,7 @@ const DpProcessPage = () => {
toggleModal()
} catch (err: any) {
if (err.response.data.message.includes('already exists')) {
setErrorDpProcessModal("Databehandlingen eksisterer allerede")
setErrorDpProcessModal('Databehandlingen eksisterer allerede')
return
}
setErrorDpProcessModal(err.response.data.message)
Expand Down

0 comments on commit f3267f4

Please sign in to comment.