Commit 1435d124 authored by Øyvind Julsrud's avatar Øyvind Julsrud
Browse files

deich-5917: deichman.no: revert laan.js

parent a4cb1a48
import { Block, Button, Container, Flex, Loader } from "@digibib/deichman-ui";
import React, { Fragment } from "react";
import { parse } from "date-fns";
import PropTypes from "prop-types";
import React, { useEffect } from "react";
import { loggedInPages } from "../../constants/navItems";
import { withAuthSync } from "../../utilities/auth";
import { connect } from "react-redux";
import FullScreen from "../../components/FullScreen";
import Head from "../../components/Head";
import SubNav from "../../components/SubNav";
import LoanList from "../../components/LoanList";
import Outlined from "../../components/Outlined";
import SubNav from "../../components/SubNav";
import { loggedInPages } from "../../constants/navItems";
import FullScreen from "../../components/FullScreen";
import { Container, Block, Loader, Button, Flex } from "@digibib/deichman-ui";
import { fetchAllProfileData } from "../../store/profile";
import { startPayFine } from "../../store/payments";
import { extendAllLoans } from "../../store/checkouts";
import { getFavourites } from "../../store/favourites";
import { startPayFine } from "../../store/payments";
import { fetchAllProfileData } from "../../store/profile";
import { withAuthSync } from "../../utilities/auth";
const dueDateComparator = (a, b) => {
if (parse(b.dueDate) < parse(a.dueDate)) {
......@@ -25,49 +26,16 @@ const dueDateComparator = (a, b) => {
return 0;
};
const MyLoans = props => {
useEffect(() => {
props.fetchAllProfileData();
props.getFavourites();
}, []);
const {
isRequestingLoansAndReservations,
personalInformation
} = props.profile;
const { loanerCategory } = personalInformation;
const isJuvenile = loanerCategory === "B" ? true : false;
const { isRequestingNetsUrl } = props.payments;
const {
loans = [],
purresaker = [],
kemnersaker = [],
remoteLoans = []
} = props.profile.loansAndReservations;
const { isRequestingExtendAllLoans, hasRequestedRenewAll } = props.checkouts;
const sortedActiveLoans = loans
.sort(dueDateComparator)
.filter(loan => loan.isPurresak !== true && loan.isKemnersak !== true);
const sortedRemoteLoans = remoteLoans.sort(dueDateComparator);
const noLoans =
kemnersaker.length < 1 &&
purresaker.length < 1 &&
sortedActiveLoans.length < 1 &&
sortedRemoteLoans.length < 1;
let purreId = -1;
if (purresaker && purresaker.length > 0) {
purreId = purresaker[0].purreId;
class MyLoans extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
let hasPurreOrKemnerSak = false;
if (
(purresaker && purresaker.length > 0) ||
(kemnersaker && kemnersaker.length > 0)
) {
hasPurreOrKemnerSak = true;
componentDidMount() {
// TODO don't fetch if allready in state
this.props.fetchAllProfileData();
this.props.getFavourites();
}
render() {
......@@ -133,22 +101,11 @@ const MyLoans = props => {
<Block top={8} bottom={8} responsive>
<Outlined>
<LoanList
items={purresaker}
items={kemnersaker}
hasPurreOrKemnerSak={hasPurreOrKemnerSak}
isJuvenile={isJuvenile}
>
<Block>
<Flex justify="space-between">
<h3>Lån med gebyr</h3>
<Button
disabled={kemnersaker && kemnersaker.length > 0}
loading={isRequestingNetsUrl}
onClick={() => props.startPayFine(purreId)}
primary
>
Betal gebyr 100,-
</Button>
</Flex>
<h3>Lån med erstatningskrav</h3>
<p>
Det har blitt sendt ut erstatningskrav følgende lån
og bibliotekkortet ditt er derfor sperret. Du kan ikke
......
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