Skip to content

Commit

Permalink
Merge branch 'dependabot/npm_and_yarn/typescript-5.6.2' of github.com…
Browse files Browse the repository at this point in the history
…:navikt/bidrag-behandling-ui into dependabot/npm_and_yarn/typescript-5.6.2
  • Loading branch information
Drax74 committed Oct 2, 2024
2 parents 81ed3ed + ec6b5d9 commit d682435
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 193 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
root: true,
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
Expand Down Expand Up @@ -31,8 +32,8 @@ module.exports = {
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/ban-types": "warn",
"unused-imports/no-unused-vars": [
"warn",
"@typescript-eslint/no-unused-vars": [
"error",
{ vars: "all", varsIgnorePattern: "^_", args: "after-used", argsIgnorePattern: "^_" },
],
eqeqeq: ["error", "smart"],
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"scripts": {
"ts": "tsc --build",
"lint": "eslint ./src/**/*.{js,ts,tsx} package.json --quiet",
"fix-lint": "eslint ./src/**/*.{js,ts,tsx} package.json --quiet --fix",
"lint": "eslint './src/**/*.{js,ts,tsx}' package.json",
"fix-lint": "eslint './src/**/*.{js,ts,tsx}' package.json --quiet --fix",
"test": "cross-env NODE_ENV=TEST mocha --config .mocharc.js --spec ./src/__tests__/**/**/*.spec.{js,ts,tsx} --exit",
"start": "",
"env:export:local": "export $(cat env/.env.local | xargs)",
Expand All @@ -32,14 +32,14 @@
"@navikt/ds-react-internal": "3.4.3",
"@navikt/ds-tailwind": "6.16.2",
"@navikt/ds-tokens": "^6.16.2",
"@tanstack/react-query": "^5.17.9",
"@tanstack/react-query": "^5.56.2",
"@testing-library/react-hooks": "^8.0.1",
"@theme-ui/mdx": "0.16.2",
"@types/lodash": "^4.14.202",
"@types/mdx": "2.0.13",
"@unleash/proxy-client-react": "^4.1.1",
"echarts": "^5.5.1",
"express": "^4.19.2",
"express": "^4.21.0",
"lodash.debounce": "^4.0.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -59,7 +59,7 @@
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"@typescript-eslint/parser": "^8.7.0",
"autoprefixer": "^10.4.16",
"chai": "^4.3.10",
"clean-webpack-plugin": "^4.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/common/components/inntekt/BeregnetInntekter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export const BeregnetInntekter = () => {
} = useGetBehandlingV2();

const behandlingViewRules = inntekterTablesViewRules[type][rolle.rolletype] as InntektTableType[];
const behandlingColumnWitdhRules = columnWitdhRules[type][rolle.rolletype] as { [key in InntektTableType]: string };
const behandlingColumnWitdhRules = columnWitdhRules[type][rolle.rolletype] as {
[_key in InntektTableType]: string;
};

const beregnetInntekterForRolle = beregnetInntekter
.find((inntekt) => inntekt.ident === rolle.ident)
Expand Down
230 changes: 120 additions & 110 deletions src/common/components/inntekt/Opplysninger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,48 @@ const inntektTypeToOpplysningerMapper = {
årsinntekter: OpplysningerType.SKATTEPLIKTIGE_INNTEKTER,
};

export const Opplysninger = ({
fieldName,
}: {
fieldName:
| `småbarnstillegg.${string}`
| `utvidetBarnetrygd.${string}`
| `årsinntekter.${string}`
| `barnetillegg.${string}.${string}`
| `kontantstøtte.${string}.${string}`;
}) => {
type FieldName =
| `småbarnstillegg.${string}`
| `utvidetBarnetrygd.${string}`
| `årsinntekter.${string}`
| `barnetillegg.${string}.${string}`
| `kontantstøtte.${string}.${string}`;

const FeilVedInnhentingAvOffentligData = ({ fieldName }: { fieldName: FieldName }) => {
const { ident } = useInntektTableProvider();
const { ikkeAktiverteEndringerIGrunnlagsdata, roller, feilOppståttVedSisteGrunnlagsinnhenting } =
useGetBehandlingV2();
const aktiverGrunnlagFn = useAktiveGrunnlagsdata();
const virkningsdato = useVirkningsdato();
const { lesemodus, setSaveErrorState } = useBehandlingProvider();
const { resetField } = useFormContext<InntektFormValues>();
const { feilOppståttVedSisteGrunnlagsinnhenting } = useGetBehandlingV2();
const { lesemodus } = useBehandlingProvider();
const [inntektType] = fieldName.split(".");
const transformFn = transformInntekt(virkningsdato);
const feilVedInnhentingAvOffentligData = feilOppståttVedSisteGrunnlagsinnhenting?.some(
(innhentingsFeil) =>
ident === innhentingsFeil.rolle.ident &&
innhentingsFeil.grunnlagsdatatype === inntektTypeToOpplysningerMapper[inntektType]
);

return (
<>
{!lesemodus && feilVedInnhentingAvOffentligData && (
<BehandlingAlert variant="info" className="mb-2">
<Heading size="small" level="3">
{text.alert.feilVedInnhentingAvOffentligData}
</Heading>
{text.feilVedInnhentingAvOffentligData}
</BehandlingAlert>
)}
</>
);
};

export const IkkeAktiverteOpplysninger = ({ fieldName }: { fieldName: FieldName }) => {
const { ident } = useInntektTableProvider();
const { ikkeAktiverteEndringerIGrunnlagsdata, roller } = useGetBehandlingV2();
const aktiverGrunnlagFn = useAktiveGrunnlagsdata();
const virkningsdato = useVirkningsdato();
const { lesemodus, setSaveErrorState } = useBehandlingProvider();
const { resetField } = useFormContext<InntektFormValues>();
const [inntektType] = fieldName.split(".");
const transformFn = transformInntekt(virkningsdato);

if (ikkeAktiverteEndringerIGrunnlagsdata.inntekter[inntektType].length === 0) return null;

const ikkeAktiverteEndringer: { [p: string]: IkkeAktivInntektDto[] } = roller.reduce(
Expand Down Expand Up @@ -147,100 +164,93 @@ export const Opplysninger = ({
return null;

return (
<>
{feilVedInnhentingAvOffentligData && (
<BehandlingAlert variant="info" className="mb-2">
<Heading size="small" level="3">
{text.alert.feilVedInnhentingAvOffentligData}
</Heading>
{text.feilVedInnhentingAvOffentligData}
</BehandlingAlert>
)}
<Box
padding="4"
background="surface-default"
borderWidth="1"
borderRadius="medium"
borderColor="border-default"
className="w-[708px] sm:max-w-[688px]"
>
<Heading size="xsmall" level="6">
{text.alert.nyOpplysninger}
</Heading>
<BodyShort size="small">{text.alert.nyOpplysningerInfomelding}</BodyShort>
{Object.keys(ikkeAktiverteEndringer).map((key) => {
if (ikkeAktiverteEndringer[key].length < 1) return null;
const rolle = roller.find((rolle) => rolle.ident === key);
return (
<Fragment key={key}>
<BodyShort className="font-bold mt-4">
<RolleTag rolleType={rolle.rolletype} />
<PersonNavn ident={key} />
</BodyShort>
<table className="mt-2">
<thead>
<tr>
<th align="left">{text.label.opplysninger}</th>
<th align="left">{text.label.beløp}</th>
<th align="left">{text.label.status}</th>
</tr>
</thead>
<tbody>
{ikkeAktiverteEndringer[key].map(
(
{
beløp,
rapporteringstype,
periode,
endringstype,
inntektsposterSomErEndret,
},
i
) => (
<Fragment key={i + rapporteringstype}>
<tr>
<td width="250px" scope="row">
{hentVisningsnavn(rapporteringstype, periode.fom, periode.til)}
</td>
<td width="75px">{formatterBeløp(beløp)}</td>
<td width="100px">{endringstypeTilVisningsnavn(endringstype)}</td>
<Box
padding="4"
background="surface-default"
borderWidth="1"
borderRadius="medium"
borderColor="border-default"
className="w-[708px] sm:max-w-[688px]"
>
<Heading size="xsmall" level="6">
{text.alert.nyOpplysninger}
</Heading>
<BodyShort size="small">{text.alert.nyOpplysningerInfomelding}</BodyShort>
{Object.keys(ikkeAktiverteEndringer).map((key) => {
if (ikkeAktiverteEndringer[key].length < 1) return null;
const rolle = roller.find((rolle) => rolle.ident === key);
return (
<Fragment key={key}>
<BodyShort className="font-bold mt-4">
<RolleTag rolleType={rolle.rolletype} />
<PersonNavn ident={key} />
</BodyShort>
<table className="mt-2">
<thead>
<tr>
<th align="left">{text.label.opplysninger}</th>
<th align="left">{text.label.beløp}</th>
<th align="left">{text.label.status}</th>
</tr>
</thead>
<tbody>
{ikkeAktiverteEndringer[key].map(
(
{ beløp, rapporteringstype, periode, endringstype, inntektsposterSomErEndret },
i
) => (
<Fragment key={i + rapporteringstype}>
<tr>
<td width="250px" scope="row">
{hentVisningsnavn(rapporteringstype, periode.fom, periode.til)}
</td>
<td width="75px">{formatterBeløp(beløp)}</td>
<td width="100px">{endringstypeTilVisningsnavn(endringstype)}</td>
</tr>
{inntektsposterSomErEndret.map((i, index) => (
<tr
key={i.visningsnavn + index}
style={
index === inntektsposterSomErEndret.length - 1
? {
borderBottom: "1px solid black",
}
: {}
}
>
<td>{i.visningsnavn}</td>
<td>{formatterBeløp(i.beløp)}</td>
<td>{endringstypeTilVisningsnavn(i.endringstype)}</td>
</tr>
{inntektsposterSomErEndret.map((i, index) => (
<tr
key={i.visningsnavn + index}
style={
index === inntektsposterSomErEndret.length - 1
? {
borderBottom: "1px solid black",
}
: {}
}
>
<td>{i.visningsnavn}</td>
<td>{formatterBeløp(i.beløp)}</td>
<td>{endringstypeTilVisningsnavn(i.endringstype)}</td>
</tr>
))}
</Fragment>
)
)}
</tbody>
</table>
</Fragment>
);
})}
<Button
size="xsmall"
type="button"
variant="secondary"
disabled={aktiverGrunnlagFn.isPending || aktiverGrunnlagFn.isSuccess}
loading={aktiverGrunnlagFn.isPending}
className="mt-2"
onClick={onUpdate}
>
Oppdater opplysninger
</Button>
</Box>
))}
</Fragment>
)
)}
</tbody>
</table>
</Fragment>
);
})}
<Button
size="xsmall"
type="button"
variant="secondary"
disabled={aktiverGrunnlagFn.isPending || aktiverGrunnlagFn.isSuccess}
loading={aktiverGrunnlagFn.isPending}
className="mt-2"
onClick={onUpdate}
>
Oppdater opplysninger
</Button>
</Box>
);
};

export const Opplysninger = ({ fieldName }: { fieldName: FieldName }) => {
return (
<>
<FeilVedInnhentingAvOffentligData fieldName={fieldName} />
<IkkeAktiverteOpplysninger fieldName={fieldName} />
</>
);
};
2 changes: 1 addition & 1 deletion src/common/components/vedtak/VedtakWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import elementIds from "../../constants/elementIds";
import texts, { mapOpplysningtypeSomMåBekreftesTilFeilmelding, rolletypeTilVisningsnavn } from "../../constants/texts";
import { useBehandlingProvider } from "../../context/BehandlingContext";
import { useGetBehandlingV2 } from "../../hooks/useApiData";
type STEPSTYPE = { [key in ForskuddStepper]: number } | { [key in SærligeutgifterStepper]: number };
type STEPSTYPE = { [_key in ForskuddStepper]: number } | { [_key in SærligeutgifterStepper]: number };
type VedtakWrapperProps = {
feil: VedtakBeregningFeil;
steps: STEPSTYPE;
Expand Down
4 changes: 2 additions & 2 deletions src/common/context/BehandlingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ export const BehandlingContext = createContext<IBehandlingContext | null>(null);

type ForskuddSteps = {
defaultStep: ForskuddStepper;
steps: { [key in ForskuddStepper]: number };
steps: { [_key in ForskuddStepper]: number };
};

type SærligeutgifterSteps = {
defaultStep: SærligeutgifterStepper;
steps: { [key in SærligeutgifterStepper]: number };
steps: { [_key in SærligeutgifterStepper]: number };
};

export type BehandlingProviderProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/forskudd/context/ForskuddBehandlingProviderWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export type PageErrorsOrUnsavedState = {
virkningstidspunkt: { error: boolean };
boforhold: {
error: boolean;
openFields?: { [key in HusstandsbarnTables]: boolean };
openFields?: { [_key in HusstandsbarnTables]: boolean };
};
inntekt: {
error: boolean;
openFields?: {
[key in InntektTables]: boolean;
[_key in InntektTables]: boolean;
};
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/særbidrag/context/SærligeugifterProviderWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export type PageErrorsOrUnsavedState = {
};
boforhold: {
error: boolean;
openFields?: { [key in HusstandsbarnTables]: boolean };
openFields?: { [_key in HusstandsbarnTables]: boolean };
};
inntekt: {
error: boolean;
openFields?: {
[key in InntektTables]: boolean;
[_key in InntektTables]: boolean;
};
};
};
Expand Down
Loading

0 comments on commit d682435

Please sign in to comment.