From 11aeee22e027dc80a3008923b0c5ad4abc8b185f Mon Sep 17 00:00:00 2001 From: Ovidio Rodriguez Date: Wed, 13 Jul 2022 11:36:37 -0400 Subject: [PATCH 1/4] Add hover to typographh --- src/styles/PaymentTile.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/styles/PaymentTile.scss b/src/styles/PaymentTile.scss index c134c56c..a56c0ac5 100644 --- a/src/styles/PaymentTile.scss +++ b/src/styles/PaymentTile.scss @@ -23,6 +23,9 @@ .project-name{ text-transform: capitalize; } + .link:hover { + text-decoration: underline; + } } @media screen and (min-width: $sm) { From 688bb3627595eee3f32cce018832ad0e35ea5e0f Mon Sep 17 00:00:00 2001 From: Ovidio Rodriguez Date: Wed, 13 Jul 2022 11:54:01 -0400 Subject: [PATCH 2/4] Get paymentId from localStorage --- src/components/PaymentsList.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/PaymentsList.js b/src/components/PaymentsList.js index eca3f25a..43aeedeb 100644 --- a/src/components/PaymentsList.js +++ b/src/components/PaymentsList.js @@ -22,6 +22,7 @@ const PaymentsList = (props) => { payment={p} client={p.client} project={project} + active={Number(localStorage.getItem('openPayment')) == p.id ? true : false} /> From 20d37e2a12c27a0fba6c3f8829ecd5654e4a96bc Mon Sep 17 00:00:00 2001 From: Ovidio Rodriguez Date: Wed, 13 Jul 2022 11:55:38 -0400 Subject: [PATCH 3/4] handle Accordion behaviour save paymentId in Local --- src/components/PaymentTile.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/PaymentTile.js b/src/components/PaymentTile.js index e71ce3bf..72f021cb 100644 --- a/src/components/PaymentTile.js +++ b/src/components/PaymentTile.js @@ -38,9 +38,11 @@ const PaymentTile = (props) => { const { client, payment, - project + project, + active } = props + localStorage.removeItem('openPayment') const formattedDatePaid = moment.utc(parseInt(payment.date_paid, 10)).format('MM/DD/YYYY') const formattedDateIncurred = moment.utc(parseInt(payment.date_incurred, 10)).format('MM/DD/YYYY') const paymentHasBeenMade = payment.date_paid != null @@ -67,6 +69,7 @@ const PaymentTile = (props) => { const [openAllocationOverview, setOpenAllocationOverview] = useState(false) const [openDeletePayment, setOpenDeletePayment] = useState(false) const [selectedAllocation, setSelectedAllocation] = useState(null) + const [activeAccordion, setActiveAccordion] = useState(active) const addAllocation = (props) => { setOpenAddAllocationDialog(true) @@ -85,6 +88,13 @@ const PaymentTile = (props) => { const handleEditPayment = () => { history.push(`/clients/${client.id}/payments/${payment.id}/update`) } + const handleRedirect = () => { + history.push(`/clients/${client.id}`) + localStorage.setItem('openPayment', payment.id) + } + const handleAccordion = () => { + setActiveAccordion(activeAccordion ? false : true) + } const currencyInformation = selectCurrencyInformation({ currency: client.currency }) @@ -224,7 +234,10 @@ const PaymentTile = (props) => { mx={1} className='PaymentTile' > - + handleAccordion()} + > @@ -282,7 +295,12 @@ const PaymentTile = (props) => { } {project && (calculateAllocationsOtherProjects() > 0 ) && - + handleRedirect()} + > {`${totalAllocatedOtherProjects} to other projects`} } From 063eff01b812ee0c6bc2dce051d487869ffa5e2f Mon Sep 17 00:00:00 2001 From: Ovidio Rodriguez Date: Mon, 25 Jul 2022 14:55:24 -0400 Subject: [PATCH 4/4] Change LocalStorage usage to URL params --- src/components/PaymentTile.js | 4 +--- src/components/PaymentsList.js | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/PaymentTile.js b/src/components/PaymentTile.js index 72f021cb..e5abc691 100644 --- a/src/components/PaymentTile.js +++ b/src/components/PaymentTile.js @@ -42,7 +42,6 @@ const PaymentTile = (props) => { active } = props - localStorage.removeItem('openPayment') const formattedDatePaid = moment.utc(parseInt(payment.date_paid, 10)).format('MM/DD/YYYY') const formattedDateIncurred = moment.utc(parseInt(payment.date_incurred, 10)).format('MM/DD/YYYY') const paymentHasBeenMade = payment.date_paid != null @@ -89,8 +88,7 @@ const PaymentTile = (props) => { history.push(`/clients/${client.id}/payments/${payment.id}/update`) } const handleRedirect = () => { - history.push(`/clients/${client.id}`) - localStorage.setItem('openPayment', payment.id) + history.push(`/clients/${client.id}?paymentId=${payment.id}`) } const handleAccordion = () => { setActiveAccordion(activeAccordion ? false : true) diff --git a/src/components/PaymentsList.js b/src/components/PaymentsList.js index 43aeedeb..4f0f10b1 100644 --- a/src/components/PaymentsList.js +++ b/src/components/PaymentsList.js @@ -13,6 +13,10 @@ const PaymentsList = (props) => { project } = props + const activePayment = window.location.search + ? window.location.search.replace('?paymentId=', '') + : '' + const renderPaymentTiles = (payments) => { return payments.map(p => { return ( @@ -22,7 +26,7 @@ const PaymentsList = (props) => { payment={p} client={p.client} project={project} - active={Number(localStorage.getItem('openPayment')) == p.id ? true : false} + active={Number(activePayment) == p.id ? true : false} />