Skip to content

Commit

Permalink
Add shortcut to set rental fees to $15 (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagnoux authored Dec 26, 2022
1 parent 70fff09 commit ab07b4a
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lodash": "^4.17.21",
"query-string": "^7.1.1",
"react": "^17.0.2",
"react-bootstrap": "^2.0.1",
"react-bootstrap": "^2.7.0",
"react-datepicker": "^4.7.0",
"react-dom": "^17.0.2",
"react-hook-form": "^7.30.0",
Expand Down
78 changes: 60 additions & 18 deletions src/pages/People/ReturnStaging/PaymentSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import styled from "styled-components";
import { useState } from "react";
import { ButtonHTMLAttributes, useState } from "react";
import { isEmpty } from "lodash";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faEdit, faRefresh } from "@fortawesome/free-solid-svg-icons";
import { faEdit, faRefresh, faPen } from "@fortawesome/free-solid-svg-icons";
import { OverlayTrigger, Tooltip } from "react-bootstrap";

import { fmtAmount } from "lib/fmtNumber";
import { NumberField } from "components/Inputs/NumberField";
Expand Down Expand Up @@ -62,30 +63,46 @@ export function PaymentSummary() {
<td>
{isWinterSchool && (
<>
<button
className="btn"
<ButtonWithTooltip
className="btn btn-light"
onClick={() => {
overrideTotalRentals(15);
setEditTotalRental(false);
}}
title="Set rentals fees to $15"
>
<FaLayer className="fa-layers fa-fw">
<FontAwesomeIcon icon={faPen} size="xs" />
<span
className="fa-layers-text"
data-fa-transform="shrink-8 down-3"
>
15
</span>
</FaLayer>
</ButtonWithTooltip>
<ButtonWithTooltip
className="btn btn-light"
onClick={() => {
if (totalRentalsOverride == null) {
overrideTotalRentals(totalRentals);
}
setEditTotalRental((v) => !v);
}}
title="Override rentals total"
title="Manually set rental fees"
>
<FontAwesomeIcon icon={faEdit} />
</button>
{
<button
className="btn"
title="Reset rentals total to calculated fees"
onClick={() => {
overrideTotalRentals(null);
setEditTotalRental(false);
}}
>
<FontAwesomeIcon icon={faRefresh} />
</button>
}
</ButtonWithTooltip>
<ButtonWithTooltip
className="btn btn-light"
title="Reset rentals fees to default"
onClick={() => {
overrideTotalRentals(null);
setEditTotalRental(false);
}}
>
<FontAwesomeIcon icon={faRefresh} />
</ButtonWithTooltip>
</>
)}
</td>
Expand Down Expand Up @@ -142,3 +159,28 @@ const StyledTable = styled.table`
width: 1%;
}
`;

const FaLayer = styled.span`
.fa-layers-text {
transform: translate(-0.1em, 0);
font-size: 0.7em;
font-weight: 600;
}
`;

function ButtonWithTooltip(props: ButtonHTMLAttributes<HTMLButtonElement>) {
return (
<OverlayTrigger placement="top" overlay={<Tooltip>{props.title}</Tooltip>}>
{({ ref, ...triggerHandler }) => (
<button
ref={ref}
type="button"
data-toggle="tooltip"
data-placement="top"
{...triggerHandler}
{...props}
/>
)}
</OverlayTrigger>
);
}
71 changes: 50 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1019,13 +1019,20 @@
core-js-pure "^3.20.2"
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.13.16", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.2", "@babel/runtime@^7.5.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.2", "@babel/runtime@^7.5.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.17.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.9.tgz#d19fbf802d01a8cb6cf053a64e472d42c434ba72"
integrity sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.18.3":
version "7.20.7"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.7.tgz#fcb41a5a70550e04a7b708037c7c32f7f356d8fd"
integrity sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ==
dependencies:
regenerator-runtime "^0.13.11"

"@babel/template@^7.16.7", "@babel/template@^7.3.3":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155"
Expand Down Expand Up @@ -1630,17 +1637,22 @@
schema-utils "^3.0.0"
source-map "^0.7.3"

"@popperjs/core@^2.10.1", "@popperjs/core@^2.9.2":
"@popperjs/core@^2.11.5":
version "2.11.6"
resolved "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz#cee20bd55e68a1720bdab363ecf0c821ded4cd45"
integrity sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==

"@popperjs/core@^2.9.2":
version "2.11.5"
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.5.tgz#db5a11bf66bdab39569719555b0f76e138d7bd64"
integrity sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw==

"@react-aria/ssr@^3.0.1":
version "3.1.2"
resolved "https://registry.yarnpkg.com/@react-aria/ssr/-/ssr-3.1.2.tgz#665a6fd56385068c7417922af2d0d71b0618e52d"
integrity sha512-amXY11ImpokvkTMeKRHjsSsG7v1yzzs6yeqArCyBIk60J3Yhgxwx9Cah+Uu/804ATFwqzN22AXIo7SdtIaMP+g==
"@react-aria/ssr@^3.2.0":
version "3.4.1"
resolved "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.4.1.tgz#79e8bb621487e8f52890c917d3c734f448ba95e7"
integrity sha512-NmhoilMDyIfQiOSdQgxpVH2tC2u85Y0mVijtBNbI9kcDYLEiW/r6vKYVKtkyU+C4qobXhGMPfZ70PTc0lysSVA==
dependencies:
"@babel/runtime" "^7.6.2"
"@swc/helpers" "^0.4.14"

"@reduxjs/toolkit@^1.8.0":
version "1.8.1"
Expand All @@ -1652,22 +1664,22 @@
redux-thunk "^2.4.1"
reselect "^4.1.5"

"@restart/hooks@^0.4.0", "@restart/hooks@^0.4.6":
"@restart/hooks@^0.4.6", "@restart/hooks@^0.4.7":
version "0.4.7"
resolved "https://registry.yarnpkg.com/@restart/hooks/-/hooks-0.4.7.tgz#d79ca6472c01ce04389fc73d4a79af1b5e33cd39"
integrity sha512-ZbjlEHcG+FQtpDPHd7i4FzNNvJf2enAwZfJbpM8CW7BhmOAbsHpZe3tsHwfQUrBuyrxWqPYp2x5UMnilWcY22A==
dependencies:
dequal "^2.0.2"

"@restart/ui@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@restart/ui/-/ui-1.2.0.tgz#fb90251aa25f99b41ccedc78a91d2a15f3c5e0fb"
integrity sha512-oIh2t3tG8drZtZ9SlaV5CY6wGsUViHk8ZajjhcI+74IQHyWy+AnxDv8rJR5wVgsgcgrPBUvGNkC1AEdcGNPaLQ==
"@restart/ui@^1.4.1":
version "1.4.1"
resolved "https://registry.npmjs.org/@restart/ui/-/ui-1.4.1.tgz#c9057915f0708c411824eeb16c03d0108c0208d2"
integrity sha512-J7wFOx2DcmkBqCqiZgDsggLO7faiNh4Nv1/v80FmbRgP+MYpwaVDKKXLC69DA4+ejgNIsBP5ORtC74EZqO1j8A==
dependencies:
"@babel/runtime" "^7.13.16"
"@popperjs/core" "^2.10.1"
"@react-aria/ssr" "^3.0.1"
"@restart/hooks" "^0.4.0"
"@babel/runtime" "^7.18.3"
"@popperjs/core" "^2.11.5"
"@react-aria/ssr" "^3.2.0"
"@restart/hooks" "^0.4.7"
"@types/warning" "^3.0.0"
dequal "^2.0.2"
dom-helpers "^5.2.0"
Expand Down Expand Up @@ -1853,6 +1865,13 @@
"@svgr/plugin-svgo" "^5.5.0"
loader-utils "^2.0.0"

"@swc/helpers@^0.4.14":
version "0.4.14"
resolved "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.14.tgz#1352ac6d95e3617ccb7c1498ff019654f1e12a74"
integrity sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==
dependencies:
tslib "^2.4.0"

"@testing-library/dom@*":
version "8.13.0"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.13.0.tgz#bc00bdd64c7d8b40841e27a70211399ad3af46f5"
Expand Down Expand Up @@ -7622,14 +7641,14 @@ react-app-polyfill@^3.0.0:
regenerator-runtime "^0.13.9"
whatwg-fetch "^3.6.2"

react-bootstrap@^2.0.1:
version "2.4.0"
resolved "https://registry.yarnpkg.com/react-bootstrap/-/react-bootstrap-2.4.0.tgz#99bf9656e2e7a23ae1ae135d18fd5ad7c344b416"
integrity sha512-dn599jNK1Fg5GGjJH+lQQDwELVzigh/MdusKpB/0el+sCjsO5MZDH5gRMmBjRhC+vb7VlCDr6OXffPIDSkNMLw==
react-bootstrap@^2.7.0:
version "2.7.0"
resolved "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-2.7.0.tgz#4a8f0311bccac477dc925366763c536f46e4393b"
integrity sha512-Jcrn6aUuRVBeSB6dzKODKZU1TONOdhAxu0IDm4Sv74SJUm98dMdhSotF2SNvFEADANoR+stV+7TK6SNX1wWu5w==
dependencies:
"@babel/runtime" "^7.17.2"
"@restart/hooks" "^0.4.6"
"@restart/ui" "^1.2.0"
"@restart/ui" "^1.4.1"
"@types/react-transition-group" "^4.4.4"
classnames "^2.3.1"
dom-helpers "^5.2.1"
Expand Down Expand Up @@ -7939,6 +7958,11 @@ regenerate@^1.4.2:
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a"
integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==

regenerator-runtime@^0.13.11:
version "0.13.11"
resolved "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==

regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.9:
version "0.13.9"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
Expand Down Expand Up @@ -8932,6 +8956,11 @@ tslib@^2.0.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==

tslib@^2.4.0:
version "2.4.1"
resolved "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e"
integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
Expand Down

0 comments on commit ab07b4a

Please sign in to comment.