From ef323038b09d500c5b81b38bed5ba95e58da4b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Gr=C3=B6hling?= Date: Sat, 7 Sep 2024 15:16:57 +0200 Subject: [PATCH] refactor: unfinished consumptions are redundant on person account detail --- .../TableConsumptions.module.css | 7 ---- .../TableConsumptions/TableConsumptions.res | 5 --- .../PlacePersonsSetting/PersonDetail.res | 42 +++++++------------ .../PlacePersonsSetting.res | 10 ----- 4 files changed, 16 insertions(+), 48 deletions(-) diff --git a/src/components/TableConsumptions/TableConsumptions.module.css b/src/components/TableConsumptions/TableConsumptions.module.css index 26dce00..815a434 100644 --- a/src/components/TableConsumptions/TableConsumptions.module.css +++ b/src/components/TableConsumptions/TableConsumptions.module.css @@ -2,13 +2,6 @@ --cell-inline-padding: var(--padding-inline, 8px); } -.table caption { - font-size: 1.17rem; - font-weight: var(--font-weight-semibold); - margin-block: 0.25rem; - grid-column: 1 / -1; -} - .table :where(tbody, thead) { display: contents; } diff --git a/src/components/TableConsumptions/TableConsumptions.res b/src/components/TableConsumptions/TableConsumptions.res index 3249d5f..baf3e5d 100644 --- a/src/components/TableConsumptions/TableConsumptions.res +++ b/src/components/TableConsumptions/TableConsumptions.res @@ -8,16 +8,11 @@ type classesType = { @react.component let make = ( ~ariaLabelledby=?, - ~captionSlot=?, ~formatConsumption, ~onDeleteConsumption, ~unfinishedConsumptions: array, ) => { - {switch captionSlot { - | Some(slot) => - | None => React.null - }} diff --git a/src/pages/PlacePersonsSetting/PersonDetail.res b/src/pages/PlacePersonsSetting/PersonDetail.res index 6056526..343433b 100644 --- a/src/pages/PlacePersonsSetting/PersonDetail.res +++ b/src/pages/PlacePersonsSetting/PersonDetail.res @@ -15,10 +15,8 @@ let byCreatedDesc = ( @react.component let make = ( - ~formatConsumption, ~hasNext, ~hasPrevious, - ~onDeleteConsumption, ~onDeletePerson, ~onDismiss, ~onNextPerson, @@ -112,30 +110,22 @@ let make = ( }}

}} - {unfinishedConsumptions->Array.length === 0 - ?

- {React.string(`${person.name} nemá nezaúčtovaná piva.`)} - {switch (pendingTransactions, maybePersonDoc) { - | ([], Some({transactions: []})) => - <> - {React.string(` Dokonce nemá ani účetní záznam. Pokud jste tuto osobu přidali omylem, můžete jí nyní `)} - - {React.string(". S účetním záznamem to později již není možné ☝️")} - - | _ => React.null - }} -

- : } + {switch (unfinishedConsumptions, pendingTransactions, maybePersonDoc) { + | ([], [], Some({transactions: []})) => +

+ {React.string( + `${person.name} nemá nezaúčtovaná piva. Dokonce nemá ani účetní záznam. Pokud jste tuto osobu přidali omylem, můžete jí nyní `, + )} + + {React.string(". S účetním záznamem to později již není možné ☝️")} +

+ | _ => React.null + }}

{React.string("Účetní záznamy")}

diff --git a/src/pages/PlacePersonsSetting/PlacePersonsSetting.res b/src/pages/PlacePersonsSetting/PlacePersonsSetting.res index c04368b..9cc6bd3 100644 --- a/src/pages/PlacePersonsSetting/PlacePersonsSetting.res +++ b/src/pages/PlacePersonsSetting/PlacePersonsSetting.res @@ -83,7 +83,6 @@ let make = (~placeId) => { if !isUserAuthorized(UserRoles.Admin) { Exn.raiseError(`Insufficient permissions to view this page`) } - let formatConsumption = BackendUtils.getFormatConsumption(place.consumptionSymbols)
{ let unfinishedConsumptions = unfinishedConsumptionsByUser->Map.get(personId)->Option.getOr([]) { - Db.Keg.deleteConsumption( - firestore, - ~placeId, - ~kegId=consumption.kegId, - ~consumptionId=consumption.consumptionId, - )->ignore - }} onDeletePerson={_ => { Db.Person.delete(firestore, ~placeId, ~personId)->ignore }}
{slot}
{React.string("Pivo")}