diff --git a/web/src/components/style/DisabledTextField.tsx b/web/src/components/style/DisabledTextField.tsx index 33efcf83..4acc962b 100644 --- a/web/src/components/style/DisabledTextField.tsx +++ b/web/src/components/style/DisabledTextField.tsx @@ -1,4 +1,4 @@ -import { TextField, Theme } from "@mui/material"; +import { Checkbox, FormControlLabel, TextField, Theme } from "@mui/material"; import { styled } from "@mui/styles"; export const DisabledTextField = styled(TextField)(({ theme }: { theme: Theme }) => ({ @@ -7,3 +7,16 @@ export const DisabledTextField = styled(TextField)(({ theme }: { theme: Theme }) WebkitTextFillColor: theme.palette.text.primary, }, })); + +export const DisabledFormControlLabel = styled(FormControlLabel)(({ theme }: { theme: Theme }) => ({ + "& .Mui-disabled": { + color: theme.palette.text.primary, + WebkitTextFillColor: theme.palette.text.primary, + }, +})); +export const DisabledCheckbox = styled(Checkbox)(({ theme }: { theme: Theme }) => ({ + "& .Mui-disabled": { + color: theme.palette.text.primary, + WebkitTextFillColor: theme.palette.text.primary, + }, +})); diff --git a/web/src/components/style/Layout.tsx b/web/src/components/style/Layout.tsx index 52648650..5ba729e2 100644 --- a/web/src/components/style/Layout.tsx +++ b/web/src/components/style/Layout.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import { Link as RouterLink } from "react-router-dom"; +import { Link as RouterLink, useLocation } from "react-router-dom"; import { useRecoilValue } from "recoil"; import { isAuthenticated } from "../../state/auth"; import ListItemLink from "./ListItemLink"; @@ -50,6 +50,7 @@ export default function Layout({ group = null, children, ...props }) { const theme: Theme = useTheme(); const dotsMenuOpen = Boolean(anchorEl); const cfg = useRecoilValue(config); + const location = useLocation(); const [mobileOpen, setMobileOpen] = useState(true); @@ -73,43 +74,66 @@ export default function Layout({ group = null, children, ...props }) { {group != null && ( - + - + - + - + - + - + - + diff --git a/web/src/components/style/SidebarGroupList.tsx b/web/src/components/style/SidebarGroupList.tsx index c9159dd7..299b31af 100644 --- a/web/src/components/style/SidebarGroupList.tsx +++ b/web/src/components/style/SidebarGroupList.tsx @@ -12,6 +12,16 @@ export default function SidebarGroupList({ group = null }) { const isGuest = useRecoilValue(isGuestUser); const [showGroupCreationModal, setShowGroupCreationModal] = useState(false); + const openGroupCreateModal = () => { + setShowGroupCreationModal(true); + }; + + const closeGroupCreateModal = (evt, reason) => { + if (reason !== "backdropClick") { + setShowGroupCreationModal(false); + } + }; + return ( <> @@ -26,16 +36,14 @@ export default function SidebarGroupList({ group = null }) { {!isGuest && ( - setShowGroupCreationModal(true)}> + )} - {!isGuest && ( - setShowGroupCreationModal(false)} /> - )} + {!isGuest && } > ); } diff --git a/web/src/components/transactions/TransactionList.tsx b/web/src/components/transactions/TransactionList.tsx index 80aabe86..ad4cddf5 100644 --- a/web/src/components/transactions/TransactionList.tsx +++ b/web/src/components/transactions/TransactionList.tsx @@ -123,12 +123,20 @@ export default function TransactionList({ group }) { setShowTransferCreateDialog(false)} + onClose={(evt, reason) => { + if (reason !== "backdropClick") { + setShowTransferCreateDialog(false); + } + }} /> setShowPurchaseCreateDialog(false)} + onClose={(evt, reason) => { + if (reason !== "backdropClick") { + setShowPurchaseCreateDialog(false); + } + }} /> {userPermissions.can_write && ( @@ -143,12 +151,14 @@ export default function TransactionList({ group }) { > } - tooltipTitle="Create Purchase" + tooltipTitle="Purchase" + tooltipOpen onClick={() => setShowPurchaseCreateDialog(true)} /> } - tooltipTitle="Create Transfer" + tooltipTitle="Transfer" + tooltipOpen onClick={() => setShowTransferCreateDialog(true)} /> diff --git a/web/src/components/transactions/purchase/PurchaseItems.tsx b/web/src/components/transactions/purchase/PurchaseItems.tsx index dbcc8831..1d156843 100644 --- a/web/src/components/transactions/purchase/PurchaseItems.tsx +++ b/web/src/components/transactions/purchase/PurchaseItems.tsx @@ -564,7 +564,7 @@ export default function PurchaseItems({ group, transaction }: PropTypes) { !position.is_empty && ( {position.name} - + {position.price.toFixed(2)} {transaction.currency_symbol} {positionAccounts.map((accountID) => ( diff --git a/web/src/pages/accounts/AccountList.tsx b/web/src/pages/accounts/AccountList.tsx index db512d6b..6a5feebb 100644 --- a/web/src/pages/accounts/AccountList.tsx +++ b/web/src/pages/accounts/AccountList.tsx @@ -110,9 +110,11 @@ export default function AccountList({ group }) { setShowPersonalAccountEditModal(true); }; - const closeAccountEdit = () => { - setShowPersonalAccountEditModal(false); - setAccountToEdit(null); + const closeAccountEdit = (evt, reason) => { + if (reason !== "backdropClick") { + setShowPersonalAccountEditModal(false); + setAccountToEdit(null); + } }; const openClearingAccountEdit = (account) => { @@ -120,9 +122,11 @@ export default function AccountList({ group }) { setShowClearingAccountEditModal(true); }; - const closeClearingAccountEdit = () => { - setShowClearingAccountEditModal(false); - setClearingAccountToEdit(null); + const closeClearingAccountEdit = (evt, reason) => { + if (reason !== "backdropClick") { + setShowClearingAccountEditModal(false); + setClearingAccountToEdit(null); + } }; const confirmDeleteAccount = () => { @@ -260,7 +264,11 @@ export default function AccountList({ group }) { setShowPersonalAccountCreationModal(false)} + onClose={(evt, reason) => { + if (reason !== "backdropClick") { + setShowPersonalAccountCreationModal(false); + } + }} group={group} /> setShowClearingAccountCreationModal(false)} + onClose={(evt, reason) => { + if (reason !== "backdropClick") { + setShowClearingAccountCreationModal(false); + } + }} initialValues={clearingAccountToCopy} group={group} /> @@ -371,12 +383,14 @@ export default function AccountList({ group }) { > } - tooltipTitle="Create Personal Account" + tooltipTitle="Personal" + tooltipOpen onClick={() => setShowPersonalAccountCreationModal(true)} /> } - tooltipTitle="Create Clearing Account" + tooltipTitle="Clearing" + tooltipOpen onClick={openCreateDialog} /> diff --git a/web/src/pages/groups/GroupList.tsx b/web/src/pages/groups/GroupList.tsx index 14117cdc..e06c7a40 100644 --- a/web/src/pages/groups/GroupList.tsx +++ b/web/src/pages/groups/GroupList.tsx @@ -35,6 +35,16 @@ export default function GroupList() { setGroupToDelete(null); }; + const openGroupCreateModal = () => { + setShowGroupCreationModal(true); + }; + + const closeGroupCreateModal = (evt, reason) => { + if (reason !== "backdropClick") { + setShowGroupCreationModal(false); + } + }; + return ( @@ -74,11 +84,11 @@ export default function GroupList() { {!isGuest && ( <> - setShowGroupCreationModal(true)}> + - setShowGroupCreationModal(false)} /> + > )} { + const startEdit = () => { + setIsEditing(true); + }; + + const stopEdit = () => { + setIsEditing(false); + }; + + const handleSubmit = (values, { setSubmitting }) => { updateGroupMetadata({ groupID: group.id, - name: name ? name : group.name, - description: description ? description : group.description, - currencySymbol: currencySymbol ? currencySymbol : group.currency_symbol, - terms: terms ? terms : group.terms, - addUserAccountOnJoin: addUserAccountOnJoin != null ? addUserAccountOnJoin : group.add_user_account_on_join, - }).catch((err) => { - toast.error(err); - }); + name: values.name, + description: values.description, + currencySymbol: values.currencySymbol, + terms: values.terms, + addUserAccountOnJoin: values.addUserAccountOnJoin, + }) + .then((res) => { + setSubmitting(false); + setIsEditing(false); + }) + .catch((err) => { + setSubmitting(false); + toast.error(err); + }); }; const confirmLeaveGroup = () => { @@ -67,51 +88,132 @@ export default function GroupSettings({ group }) { You only have read access to this group ) : null} - updateGroup({ name: name })} - /> - - updateGroup({ description: description })} - /> - - updateGroup({ currencySymbol: currencySymbol })} - /> - - updateGroup({ terms: terms })} - /> - - updateGroup({ addUserAccountOnJoin: e.target.checked })} - checked={group.add_user_account_on_join} - /> - } - label="Automatically add accounts for newly joined group members" - /> + + {({ values, handleBlur, handleChange, handleSubmit, isSubmitting }) => ( + + + + + + + + + } + label="Automatically add accounts for newly joined group members" + /> + + + {isSubmitting && } + + + {userPermissions.can_write && isEditing && ( + <> + } + > + Save + + } + sx={{ ml: 1 }} + > + Cancel + + > + )} + {userPermissions.can_write && !isEditing && ( + } + > + Edit + + )} + + setShowLeaveModal(true)}> + Leave Group + + + + )} + {/**/} {/* */} @@ -122,12 +224,6 @@ export default function GroupSettings({ group }) { {/* */} {/**/} - - setShowLeaveModal(true)}> - Leave Group - - - setShowLeaveModal(false)}> Leave Group