Commit 1122a774 authored by Torstein Nicolaysen's avatar Torstein Nicolaysen Committed by Torstein
Browse files

DEICH-5925 fix formatting and values in table

parent c9925b39
......@@ -4,6 +4,8 @@ import { useRouter } from "next/router";
import React, { Fragment, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { fetchChildPatrons } from "../../store/adminSearch";
import { formatDateFromISOString } from "../../utilities/datetime";
import "./styles.css";
const initialValues = date => {
......@@ -25,6 +27,10 @@ const validateForm = values => {
};
const formateDate = date => {
if (!date) {
return "";
}
const [d1, d2, m1, m2, y1, y2, y3, y4] = date.split("");
return `${d1}${d2}.${m1}${m2}.${y1}${y2}${y3}${y4}`;
......@@ -73,6 +79,27 @@ const ChildPatronAdminSearch = () => {
router.push("/ansatt/ny-bruker");
};
const formatCategoryCode = categorycode => {
switch (categorycode) {
case "B":
return "Barn";
case "REGBARN":
return "Selvregistrert barn";
case "REGBARNWEB":
return "Selvregistrert barn (fra web)";
default:
return categorycode;
}
};
const formatDateOfBirth = dob => {
if (!dob) {
return "UKJENT";
}
return formatDateFromISOString(dob);
};
return (
<div className="child-patron-admin-search">
<form onSubmit={handleSubmit} disabled={false}>
......@@ -98,7 +125,7 @@ const ChildPatronAdminSearch = () => {
}
primary
>
Legg til låner
Søk
</Button>
</div>
</div>
......@@ -133,10 +160,10 @@ const ChildPatronAdminSearch = () => {
<b>{obj?.name}</b>
</Table.Cell>
<Table.Cell label="Kategori">
<b>{obj?.category}</b>
<b>{formatCategoryCode(obj?.categorycode)}</b>
</Table.Cell>
<Table.Cell label="Fødselsdato">
<b>{obj?.dateOfBirth}</b>
<b>{formatDateOfBirth(obj?.dateofbirth)}</b>
</Table.Cell>
<Table.Cell label="">
<span className="child-patron-admin-search__register-text">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment