Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #928 from navikt/moment-be-gone
Browse files Browse the repository at this point in the history
Fjern moment
  • Loading branch information
jrtm authored Jul 26, 2021
2 parents 26f36b0 + 5ab9739 commit 0d78ddf
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 73 deletions.
8 changes: 1 addition & 7 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import moment from "moment";
import {alleFeatureToggles} from "../../src/ducks/feature-toggles";
import {FEATURE_URL} from "../../src/ducks/api";

Expand Down Expand Up @@ -52,12 +51,7 @@ Cypress.Commands.add('configure', option => {
cy.route('GET', '/pam-janzz/rest/typeahead/yrke-med-styrk08?q=Klovn', 'fixture:tidligere-yrke');
cy.route('POST', '/veilarbregistrering/api/startregistrersykmeldt', {})
.as('startregistrersykemeldt');
cy.fixture('startregistrering/registrering-sykefravaer')
.then(fixture => {
// Setter dato tretten uker frem i tid
fixture.maksDato = moment(new Date(), 'DD.MM.YYYY').add(13, 'week');
cy.route('GET', '/veilarbregistrering/api/startregistrering', fixture);
});
cy.route('GET', '/veilarbregistrering/api/startregistrering', 'fixture:/startregistrering/registrering-sykefravaer')
break;
case 'reaktivering':
cy.on('window:before:load', win => {
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"less-plugin-npm-import": "2.1.0",
"lodash": "4.17.21",
"lodash.throttle": "4.1.1",
"moment": "2.29.1",
"nav-frontend-alertstriper": "4.0.1",
"nav-frontend-alertstriper-style": "3.0.1",
"nav-frontend-chevron": "1.0.30",
Expand Down
1 change: 0 additions & 1 deletion src/app-fss.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from "react";
import "moment/locale/nb";
import { Provider } from "react-redux";
import IntlProvider from "./Intl-provider";
import { getStore } from "./store";
Expand Down
1 change: 0 additions & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from "react";
import "moment/locale/nb";
import { Provider } from "react-redux";
import IntlProvider from "./Intl-provider";
import { getStore } from "./store";
Expand Down
4 changes: 0 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ import "idempotent-babel-polyfill";
import "react-app-polyfill/ie11";
import Modal from "react-modal";
import * as Sentry from "@sentry/react";
import moment from "moment";
import "moment/locale/nb";
import { erIFSS } from "./utils/fss-utils";
import App from "./app";
import AppFss from "./app-fss";
import "./index.less";
import { erNAVMiljo } from "./utils/url-utils";

moment.locale("nb");

Modal.setAppElement("#root");

if (process.env.REACT_APP_MOCK) {
Expand Down
58 changes: 0 additions & 58 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import moment from "moment";

export function hentFornavn(name: string | undefined) {
return name ? storForbokstavOgEtterBindestrek(name.split(" ")[0]) : "";
}
Expand Down Expand Up @@ -33,62 +31,6 @@ export interface MatchProps {
id: string;
}

/*
* Regn ut alder basert på fnr som kommer fra `veilarboppfolging/api/me`
* Senere kan koden under bli erstattes med at backend regner ut alder istenfor
* */

function erDNummer(personId: string) {
const forsteSiffer = Number(personId.substring(0, 1));
return forsteSiffer > 3 && forsteSiffer < 8;
}

function parseDNummer(personId: string) {
return !erDNummer(personId) ? personId : personId.substring(1);
}

function toSifferFodselsAar(personId: string) {
return personId.substring(4, 6);
}

function hentAarhundre(personId: string) {
let result;
const individNummer = Number(personId.substring(6, 9));
const fodselsAar = Number(personId.substring(4, 6));

if (individNummer <= 499) {
result = "19";
} else if (individNummer >= 500 && fodselsAar < 40) {
result = "20";
} else if (individNummer >= 500 && individNummer <= 749 && fodselsAar >= 54) {
result = "18";
} else if (individNummer >= 900 && fodselsAar > 39) {
result = "19";
}

return result;
}

export function formaterDato(dato: string | undefined) {
if (!dato) {
return "";
}

return moment(dato, "YYYY-MM-DD").format("DD. MMMM YYYY");
}

export function hentAlder(personId: string) {
const fnr = parseDNummer(personId);

const aarhundre = hentAarhundre(fnr);
const fnrForsteFireSiffer = fnr.substring(0, 4);
const toSifferFAar = toSifferFodselsAar(fnr);

const fodselsdato = moment(`${fnrForsteFireSiffer}${aarhundre}${toSifferFAar}`, "DDMMYYYY");

return moment().diff(fodselsdato, "years");
}

export function scrollToBanner() {
let scrollHeight = 0;
const header = document.querySelector(".siteheader");
Expand Down

0 comments on commit 0d78ddf

Please sign in to comment.