Skip to content

Commit

Permalink
Fix for SWR henting av navn på Bostedsadresse.tsx
Browse files Browse the repository at this point in the history
#deploy-test-frontend
  • Loading branch information
stigus committed Oct 5, 2023
1 parent 17d9ded commit 245ee59
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { DatepickerWrapper } from '@/components/ui/form/inputs/datepicker/Datepi
import { Adressetype } from '@/components/fagsystem/pdlf/PdlTypes'
import { SelectOptionsOppslag } from '@/service/SelectOptionsOppslag'
import { getPlaceholder, setNavn } from '@/components/fagsystem/pdlf/form/partials/utils'
import {useGenererNavn} from "@/utils/hooks/useGenererNavn";
import { useGenererNavn } from '@/utils/hooks/useGenererNavn'

interface BostedsadresseValues {
formikBag: FormikProps<{}>
Expand Down Expand Up @@ -123,7 +123,7 @@ export const BostedsadresseForm = ({
formikBag.setFieldValue(path, adresseClone)
}

const {navnInfo} = useGenererNavn()
const { navnInfo, loading } = useGenererNavn()
const navnOptions = SelectOptionsOppslag.formatOptions('personnavn', navnInfo)

return (
Expand Down Expand Up @@ -165,7 +165,7 @@ export const BostedsadresseForm = ({
options={navnOptions}
size="xlarge"
placeholder={getPlaceholder(formikBag.values, `${path}.opprettCoAdresseNavn`)}
isLoading={navnInfo.loading}
isLoading={loading}
onChange={(navn: Target) =>
setNavn(navn, `${path}.opprettCoAdresseNavn`, formikBag.setFieldValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const concatNavnMedTidligereValgt = (type, navnInfo, selectedNavn) => {
if (!navnInfo) {
return []
}
const formattedNavnInfo = { loading: false, value: { data: navnInfo } }
const navnOptions = SelectOptionsOppslag.formatOptions(type, formattedNavnInfo)
const navnOptions = SelectOptionsOppslag.formatOptions(type, navnInfo)
.concat(
selectedNavn?.map((navn) => ({
value: navn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ const DollyTooltip = ({
}
return useExternalTooltip ? (
<span data-cy={dataCy}>
<RcTooltip.default
overlay={content}
placement="top"
mouseEnterDelay={0.1}
mouseLeaveDelay={0.1}
{...rest}
>
<RcTooltip.default overlay={content} placement="top" {...rest}>
{children}
</RcTooltip.default>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function PersonListe({
dataField: 'navn',
formatter: (_cell, row) => {
return (
<DollyTooltip content={row.navn?.length > 23 ? row.navn : null} mouseEnterDelay={0}>
<DollyTooltip content={row.navn?.length > 23 ? row.navn : null}>
{getNavnLimited(row.navn)}
</DollyTooltip>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useAsync } from 'react-use'
import { BrregstubApi, DollyApi, KrrApi, PdlforvalterApi } from '@/service/Api'
import { getGenererNavn } from '@/utils/hooks/useGenererNavn'
import Api from '@/api'
import * as _ from 'lodash-es'
import { Person, PersonData } from '@/components/fagsystem/pdlf/PdlTypes'
Expand Down Expand Up @@ -210,5 +209,5 @@ export const SelectOptionsOppslag = {
})
return options
}
}
},
}
15 changes: 10 additions & 5 deletions apps/dolly-frontend/src/main/js/src/utils/hooks/useGenererNavn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ export const useGenererNavn = () => {

return {
data: data,
navnInfo: data?.map((element: any) => ({
fornavn: element.adjektiv,
mellomnavn: element.adverb,
etternavn: element.substantiv,
})),
navnInfo: {
value: {
data: data?.map((element: any) => ({
fornavn: element.adjektiv,
mellomnavn: element.adverb,
etternavn: element.substantiv,
})),
loading: isLoading,
},
},
loading: isLoading,
error: error,
mutate: mutate,
Expand Down

0 comments on commit 245ee59

Please sign in to comment.