Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reason for failed loan renewal #1043

Merged
merged 4 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/apps/loan-list/list/loan-list.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import loanGroupModalArgs from "../../../core/storybook/loanGroupModalArgs";
import materialDetailsModalArgs from "../../../core/storybook/materialDetailsModalArgs";
import renewalArgs from "../../../core/storybook/renewalArgs";
import { getModalIds } from "../../../core/utils/helpers/modal-helpers";
import globalConfigArgs from "../../../core/storybook/globalConfigArgs";

export default {
title: "Apps / Loan list",
Expand All @@ -18,6 +19,7 @@ export default {
...serviceUrlArgs,
...groupModalArgs,
...globalTextArgs,
...globalConfigArgs,
...loanGroupModalArgs,
...renewalArgs,
...materialDetailsModalArgs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ const StatusMessage: FC<StatusMessageProps> = ({
return (
<>
{renewalStatusList &&
renewalStatusList.map((text) => (
<span className={className}>{getStatusText(text, t)}</span>
))}
renewalStatusList.map((text) => {
if (text !== "deniedOtherReason") {
return <span className={className}>{getStatusText(text, t)}</span>;
}
return null;
})}
{loanType === "interLibraryLoan" && (
<span className={className}>
{t("groupModalRenewLoanDeniedInterLibraryLoanText")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
formatDate,
formatDateTime
} from "../../../../core/utils/helpers/date";
import StatusMessage from "../selectable-material/StatusMessage";

interface MaterialStatusProps {
loan: LoanType;
Expand Down Expand Up @@ -77,6 +78,16 @@ const MaterialStatus: FC<MaterialStatusProps> = ({
placeholders: { "@date": formatDate(dueDate) }
})}
</p>
{!isDigital(loan) && (
<p className="text-small-caption color-secondary-gray mt-4">
<StatusMessage
className="mr-4"
loanType={loan.loanType}
renewalStatusList={loan.renewalStatusList}
/>
</p>
)}

{children}
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/apps/loan-list/modal/material-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const MaterialDetails: FC<MaterialDetailsProps & MaterialProps> = ({
isRenewable,
materialItemNumber,
loanDate,
periodical
loanType,
periodical,
renewalStatusList
} = loan;
const { authors, materialType, year, title, pid, description, series } =
material || {};
Expand Down Expand Up @@ -111,8 +113,10 @@ const MaterialDetails: FC<MaterialDetailsProps & MaterialProps> = ({
renewable={isRenewable}
hideOnMobile
renewingStatus={renewingStatus}
loanType={loanType || ""}
setRenewingStatus={setRenewingStatus}
setRenewingResponse={setRenewingResponse}
renewalStatusList={renewalStatusList}
/>
)}
{isDigital(loan) && (
Expand Down Expand Up @@ -175,9 +179,11 @@ const MaterialDetails: FC<MaterialDetailsProps & MaterialProps> = ({
loanId={loanId}
renewable={isRenewable}
hideOnMobile={false}
loanType={loanType || ""}
renewingStatus={renewingStatus}
setRenewingStatus={setRenewingStatus}
setRenewingResponse={setRenewingResponse}
renewalStatusList={renewalStatusList}
/>
)}
{isDigital(loan) && (
Expand Down
15 changes: 15 additions & 0 deletions src/apps/loan-list/modal/renew-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RenewedLoanV2 } from "../../../core/fbs/model";
import { getRenewButtonLabel } from "../../../core/utils/helpers/renewal";
import { useStatistics } from "../../../core/statistics/useStatistics";
import { statistics } from "../../../core/statistics/statistics";
import StatusMessage from "../materials/selectable-material/StatusMessage";

interface RenewButtonProps {
loanId: LoanId;
Expand All @@ -17,6 +18,8 @@ interface RenewButtonProps {
hideOnMobile: boolean;
setRenewingStatus: (status: RequestStatus) => void;
renewingStatus: RequestStatus;
renewalStatusList: string[];
loanType: string;
setRenewingResponse: (response: RenewedLoanV2[] | null) => void;
}

Expand All @@ -27,6 +30,8 @@ const RenewButton: FC<RenewButtonProps> = ({
hideOnMobile,
setRenewingStatus,
renewingStatus,
renewalStatusList,
loanType,
setRenewingResponse
}) => {
const t = useText();
Expand Down Expand Up @@ -76,6 +81,11 @@ const RenewButton: FC<RenewButtonProps> = ({
hideOnMobile && `modal-details__buttons--hide-on-mobile`
} modal-details__buttons`}
>
<StatusMessage
className="list-materials__status__note-desktop mt-48 mr-16"
loanType={loanType}
renewalStatusList={renewalStatusList}
/>
<Button
dataCy="material-renew-button"
size="small"
Expand All @@ -90,6 +100,11 @@ const RenewButton: FC<RenewButtonProps> = ({
buttonType="none"
collapsible={false}
/>
<StatusMessage
className="list-materials__status__note-mobile mt-8"
loanType={loanType}
renewalStatusList={renewalStatusList}
/>
</div>
);
};
Expand Down
Loading