Skip to content

Commit

Permalink
Mer bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed Sep 20, 2023
1 parent 7abbfb0 commit 1008623
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export const sjekkManglerSykemeldingBestilling = (sykemeldingBestilling) => {
}

const VisningAvBestilling = ({ bestillinger }) => {
return bestillinger.map((bestilling: SykemeldingSynt | SykemeldingDetaljert, idx: number) => {
if (!bestillinger) {
return null
}

return bestillinger?.map((bestilling: SykemeldingSynt | SykemeldingDetaljert, idx: number) => {
if (!bestilling.erGjenopprettet) {
const syntSykemelding = _.get(bestilling, 'data.sykemelding.syntSykemelding')
const detaljertSykemelding = _.get(bestilling, 'data.sykemelding.detaljertSykemelding')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import { useAsync } from 'react-use'
import { DollyApi } from '@/service/Api'

type Bestilling = {
data: Array<BestillingData>
}

type BestillingData = {
status: string
}
import { useTransaksjonsid } from '@/utils/hooks/useTransaksjonsid'

export const erGyldig = (bestillingId: number, system: string, ident: string) => {
const finnBestilling = useAsync(async () => {
const response: Bestilling = await DollyApi.getTransaksjonid(system, ident, bestillingId)
return response.data
}, [])

return finnBestilling.value && finnBestilling.value.length > 0
const { transaksjonsid, loading } = useTransaksjonsid(system, ident, bestillingId)
return !loading && transaksjonsid && transaksjonsid.length > 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import {
useInstData,
usePoppData,
useTpData,
useTransaksjonidData,
useTransaksjonIdData,
} from '@/utils/hooks/useFagsystemer'
import { sjekkManglerTpData } from '@/components/fagsystem/tjenestepensjon/visning/TpVisning'
Expand Down Expand Up @@ -201,7 +200,7 @@ export default ({
pensjonEnvironments,
)

const { loading: loadingSykemeldingData, data: sykemeldingData } = useTransaksjonidData(
const { loading: loadingSykemeldingData, data: sykemeldingData } = useTransaksjonIdData(
ident.ident,
'SYKEMELDING',
harSykemeldingBestilling(bestillingerFagsystemer),
Expand Down
11 changes: 0 additions & 11 deletions apps/dolly-frontend/src/main/js/src/utils/hooks/useBestilling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ export const useBestillingerGruppe = (gruppeId: string | number) => {
getBestillingerGruppeUrl(gruppeId),
fetcher,
)
// console.log('data sfsfsfsafasfs: ', data) //TODO - SLETT MEG
const getSykemeldingBestilling = () => {
const sykemeldingId = []
data?.forEach((i) => {
if (i.bestilling.sykemelding) {
sykemeldingId.push(i.id)
}
})
return sykemeldingId
}
console.log('getSykemeldingBestilling(): ', getSykemeldingBestilling()) //TODO - SLETT MEG

const bestillingerSorted = data
?.sort((bestilling, bestilling2) => (bestilling.id < bestilling2.id ? 1 : -1))
Expand Down
38 changes: 0 additions & 38 deletions apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,44 +126,6 @@ export const useTransaksjonIdData = (ident, system, harBestilling, fagsystemMilj
}
}

export const useTransaksjonidData = (
ident,
system,
harBestilling,
fagsystemMiljoer = null,
fagsystemLoading = false,
) => {
const { data, isLoading, error } = useSWR<any, Error>(
harBestilling ? `/dolly-backend/api/v1/transaksjonid?ident=${ident}&system=${system}` : null,
fetcher,
)

const getMiljoData = () => {
if (!harBestilling || !data) {
return null
}
const miljoData = []
if (fagsystemMiljoer && fagsystemMiljoer.length > 0) {
fagsystemMiljoer.map((miljo) => {
const fagsystemData = data?.find((d) => d?.miljoe === miljo)?.transaksjonId
miljoData.push({ data: fagsystemData, miljo: miljo })
})
} else {
data?.map((m) => {
miljoData.push({ data: m.transaksjonId, miljo: m.miljoe })
})
}
return miljoData
}
const miljoData = getMiljoData()

return {
data: miljoData?.sort((a, b) => a.miljo?.localeCompare(b.miljo)),
loading: fagsystemLoading || isLoading,
error: error,
}
}

export const useInstData = (ident, harInstBestilling) => {
const { instEnvironments } = useInstEnvironments()

Expand Down

0 comments on commit 1008623

Please sign in to comment.