Skip to content

Commit

Permalink
Opprydning
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed Aug 21, 2024
1 parent 5609dd0 commit 066f5e3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const FinnPersonDropdown = () => {
Søk i Tenor
</Dropdown.Menu.List.Item>
<Dropdown.Menu.List.Item
// data-testid={TestComponentSelectors.BUTTON_HEADER_TENOR}
onClick={() => navigate('/nyansettelser/')}
style={{ color: '#212529' }}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React, { useState } from 'react'
import { Alert, Box, Pagination, Search, Table, VStack } from '@navikt/ds-react'
import {
useLevendeArbeidsforholdIdentsoek,
useLevendeArbeidsforholdLogg,
} from '@/utils/hooks/useLevendeArbeidsforhold'
import { Alert, Box, Pagination, Table, VStack } from '@navikt/ds-react'
import { useLevendeArbeidsforholdLogg } from '@/utils/hooks/useLevendeArbeidsforhold'
import { formatDate } from '@/utils/DataFormatter'
import { ArbeidKodeverk } from '@/config/kodeverk'
import { useKodeverk } from '@/utils/hooks/useKodeverk'
Expand Down Expand Up @@ -38,7 +35,6 @@ export default () => {
return (
<>
<h1>Nyansettelser</h1>
{/*TODO: Endre alt til ansettelser?*/}
<VStack gap="4">
<NyansettelserSoek
setIdentSoekData={setIdentSoekData}
Expand All @@ -48,7 +44,7 @@ export default () => {
<Box background="surface-default" padding="4">
{loading ? (
<Loading label="Laster arbeidsforhold ..." />
) : sortData?.length < 1 ? (
) : !sortData || sortData?.length < 1 ? (
<Alert variant={'info'}>Fant ingen arbeidsforhold</Alert>
) : (
<div>
Expand Down Expand Up @@ -85,7 +81,7 @@ export default () => {
<Table.DataCell width={'15%'}>{formatDate(row.ansattfra)}</Table.DataCell>
<Table.DataCell width={'30%'}>
{kodeverk?.length > 0
? kodeverk?.find((kode) => kode?.value === row.arbeidsforholdType)
? kodeverk?.find((kode: any) => kode?.value === row.arbeidsforholdType)
?.label
: row.arbeidsforholdType}
</Table.DataCell>
Expand All @@ -101,7 +97,7 @@ export default () => {
onPageChange={setPage}
count={Math.ceil(visData()?.length / rowsPerPage)}
size="small"
style={{ marginTop: '20px', justifyContent: 'center' }}
style={{ marginTop: '20px' }}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Button, Search, ToggleGroup } from '@navikt/ds-react'
import { Box, Search, ToggleGroup } from '@navikt/ds-react'
import React, { useState } from 'react'
import { PersonIcon, TenancyIcon } from '@navikt/aksel-icons'
import { Form, FormProvider, useForm } from 'react-hook-form'
Expand All @@ -10,7 +10,7 @@ enum SoekKategorier {
ORGNR = 'orgnr',
}

export const NyansettelserSoek = ({ setIdentSoekData, setOrgnummerSoekData, setPage }) => {
export const NyansettelserSoek = ({ setIdentSoekData, setOrgnummerSoekData, setPage }: any) => {
const [soekKategori, setSoekKategori] = useState(SoekKategorier.IDENT)
const [soekValue, setSoekValue] = useState(null)

Expand All @@ -20,12 +20,12 @@ export const NyansettelserSoek = ({ setIdentSoekData, setOrgnummerSoekData, setP
return
}
if (soekKategori === SoekKategorier.ORGNR) {
await Request.get(getOrgnummerUrl(soekValue)).then((response) => {
await Request.get(getOrgnummerUrl(soekValue)).then((response: any) => {
setOrgnummerSoekData(response.data)
setPage(1)
})
} else {
await Request.get(getIdentUrl(soekValue)).then((response) => {
await Request.get(getIdentUrl(soekValue)).then((response: any) => {
setIdentSoekData(response.data)
setPage(1)
})
Expand All @@ -34,11 +34,9 @@ export const NyansettelserSoek = ({ setIdentSoekData, setOrgnummerSoekData, setP

const formMethods = useForm({
mode: 'onSubmit',
// resolver: yupResolver(validation()),
})

const nullstill = () => {
formMethods.reset()
setSoekValue(null)
setIdentSoekData(null)
setOrgnummerSoekData(null)
Expand All @@ -64,12 +62,7 @@ export const NyansettelserSoek = ({ setIdentSoekData, setOrgnummerSoekData, setP
/>
</ToggleGroup>
<FormProvider {...formMethods}>
<Form
control={formMethods.control}
// className={'opprett-tabellrad'}
autoComplete={'off'}
onSubmit={formMethods.handleSubmit(onSubmit)}
>
<Form onSubmit={formMethods.handleSubmit(onSubmit)}>
<div className="flexbox--flex-wrap" style={{ marginTop: '15px' }}>
<Search
label="Søk etter personident"
Expand All @@ -84,9 +77,6 @@ export const NyansettelserSoek = ({ setIdentSoekData, setOrgnummerSoekData, setP
}}
onClear={nullstill}
/>
{/*<Button variant="tertiary" size="small" onClick={nullstill}>*/}
{/* Nullstill*/}
{/*</Button>*/}
</div>
</Form>
</FormProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { fetcher } from '@/api'

const levenedeArbeidsforholdUrl = '/testnav-levende-arbeidsforhold-ansettelse/api/v1/logg'

const getLoggUrl = (page: number, size: number, sort: string) => {
return `${levenedeArbeidsforholdUrl}?page=${page}&size=${size}&sort=${sort}`
}

export const getIdentUrl = (ident: string) => {
return `${levenedeArbeidsforholdUrl}/ident/${ident}`
}
Expand All @@ -15,6 +11,10 @@ export const getOrgnummerUrl = (orgnummer: string) => {
return `${levenedeArbeidsforholdUrl}/organisasjon/${orgnummer}`
}

const getLoggUrl = (page: number, size: number, sort: string) => {
return `${levenedeArbeidsforholdUrl}?page=${page}&size=${size}&sort=${sort}`
}

export const useLevendeArbeidsforholdLogg = (page: number, size: number, sort: string) => {
const { data, isLoading, error } = useSWR<any, Error>(getLoggUrl(page, size, sort), fetcher)

Expand All @@ -24,20 +24,3 @@ export const useLevendeArbeidsforholdLogg = (page: number, size: number, sort: s
error: error,
}
}

export const useLevendeArbeidsforholdIdentsoek = (ident: string) => {
console.log('ident: ', ident) //TODO - SLETT MEG
if (!ident) {
return {
loading: false,
error: 'Ident mangler!',
}
}
const { data, isLoading, error } = useSWR<any, Error>(getIdentUrl(ident), fetcher)

return {
identData: data,
loading: isLoading,
error: error,
}
}

0 comments on commit 066f5e3

Please sign in to comment.