From 56ac01580ce995e620bf4f944af9bd3b16b80f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Loipf=C3=BChrer?= Date: Fri, 16 Aug 2024 10:36:22 +0200 Subject: [PATCH] refactor(web): normalize exports and other improvements --- .../apps/mobile/src/navigation/Navigation.tsx | 20 +-- frontend/apps/mobile/src/screens/Register.tsx | 4 +- frontend/apps/web/src/app/app.tsx | 2 +- .../authenticated-layout/SidebarGroupList.tsx | 4 +- .../apps/web/src/components/ShareSelect.tsx | 6 +- .../accounts/AccountClearingListEntry.tsx | 3 +- .../accounts/AccountTransactionListEntry.tsx | 3 +- .../src/components/accounts/BalanceTable.tsx | 24 ++-- .../accounts/ClearingAccountDetail.tsx | 9 +- .../apps/web/src/components/accounts/index.ts | 6 + .../components/groups/GroupCreateModal.tsx | 2 - .../apps/web/src/components/groups/index.ts | 4 + frontend/apps/web/src/components/index.ts | 7 + .../src/components/style/EditableField.tsx | 2 - .../web/src/components/style/ListItemLink.tsx | 4 +- .../apps/web/src/components/style/Loading.tsx | 2 - .../{mobile/index.tsx => MobilePaper.tsx} | 0 .../apps/web/src/components/style/index.ts | 7 + frontend/apps/web/src/core/config.tsx | 2 +- .../accounts/AccountDetail/AccountDetail.tsx | 3 +- .../apps/web/src/pages/accounts/Balances.tsx | 5 +- .../ClearingAccountList.tsx | 2 +- .../PersonalAccountList.tsx | 2 +- .../pages/accounts/SettlementPlanDisplay.tsx | 2 +- .../src/pages/auth/ConfirmRegistration.tsx | 2 +- frontend/apps/web/src/pages/groups/Group.tsx | 124 ++++-------------- .../apps/web/src/pages/groups/GroupInvite.tsx | 3 +- .../web/src/pages/groups/GroupInvites.tsx | 2 +- .../apps/web/src/pages/groups/GroupList.tsx | 7 +- .../apps/web/src/pages/groups/GroupLog.tsx | 2 +- .../web/src/pages/groups/GroupMemberList.tsx | 2 +- .../web/src/pages/groups/GroupSettings.tsx | 2 +- .../web/src/pages/profile/ChangeEmail.tsx | 2 +- .../web/src/pages/profile/ChangePassword.tsx | 2 +- .../apps/web/src/pages/profile/Profile.tsx | 3 +- .../web/src/pages/profile/SessionList.tsx | 3 +- .../apps/web/src/pages/profile/Settings.tsx | 2 +- .../TransactionDetail/FileGallery.tsx | 2 +- .../TransactionDetail/TransactionDetail.tsx | 3 +- .../purchase/TransactionPositions.tsx | 2 +- .../TransactionList/TransactionList.tsx | 2 +- 41 files changed, 105 insertions(+), 185 deletions(-) create mode 100644 frontend/apps/web/src/components/accounts/index.ts create mode 100644 frontend/apps/web/src/components/groups/index.ts create mode 100644 frontend/apps/web/src/components/index.ts rename frontend/apps/web/src/components/style/{mobile/index.tsx => MobilePaper.tsx} (100%) create mode 100644 frontend/apps/web/src/components/style/index.ts diff --git a/frontend/apps/mobile/src/navigation/Navigation.tsx b/frontend/apps/mobile/src/navigation/Navigation.tsx index cbca5b7e..d8453307 100644 --- a/frontend/apps/mobile/src/navigation/Navigation.tsx +++ b/frontend/apps/mobile/src/navigation/Navigation.tsx @@ -11,17 +11,17 @@ import { useOptionalApi } from "../core/ApiProvider"; import { notify } from "../notifications"; import { AddGroup } from "../screens/AddGroup"; import { GroupList } from "../screens/GroupList"; -import HomeScreen from "../screens/HomeScreen"; -import LoginScreen from "../screens/Login"; -import PreferencesScreen from "../screens/PreferencesScreen"; -import ProfileScreen from "../screens/ProfileScreen"; -import RegisterScreen from "../screens/Register"; +import { HomeScreen } from "../screens/HomeScreen"; +import { LoginScreen } from "../screens/Login"; +import { PreferencesScreen } from "../screens/PreferencesScreen"; +import { ProfileScreen } from "../screens/ProfileScreen"; +import { RegisterScreen } from "../screens/Register"; import { SplashScreen } from "../screens/SplashScreen"; import { TransactionList } from "../screens/TransactionList"; -import AccountDetail from "../screens/groups/AccountDetail"; -import AccountEdit from "../screens/groups/AccountEdit"; -import AccountList from "../screens/groups/AccountList"; -import TransactionDetail from "../screens/groups/TransactionDetail"; +import { AccountDetail } from "../screens/groups/AccountDetail"; +import { AccountEdit } from "../screens/groups/AccountEdit"; +import { AccountList } from "../screens/groups/AccountList"; +import { TransactionDetail } from "../screens/groups/TransactionDetail"; import { changeActiveGroup, selectActiveGroupId, @@ -32,7 +32,7 @@ import { useAppSelector, } from "../store"; import { Theme } from "../theme"; -import DrawerContent from "./DrawerContent"; +import { DrawerContent } from "./DrawerContent"; import { Header } from "./Header"; import { linkingOptions } from "./LinkingConfiguration"; import { GroupStackParamList, GroupTabParamList, RootDrawerParamList } from "./types"; diff --git a/frontend/apps/mobile/src/screens/Register.tsx b/frontend/apps/mobile/src/screens/Register.tsx index 3afac65b..459edebd 100644 --- a/frontend/apps/mobile/src/screens/Register.tsx +++ b/frontend/apps/mobile/src/screens/Register.tsx @@ -34,7 +34,7 @@ const initialValues: FormSchema = { password2: "", }; -export const Register: React.FC> = ({ navigation }) => { +export const RegisterScreen: React.FC> = ({ navigation }) => { const { t } = useTranslation(); const theme = useTheme(); const loggedIn = useAppSelector((state) => selectIsAuthenticated({ state: selectAuthSlice(state) })); @@ -182,5 +182,3 @@ const styles = StyleSheet.create({ // color: theme.colors.primary, }, }); - -export default Register; diff --git a/frontend/apps/web/src/app/app.tsx b/frontend/apps/web/src/app/app.tsx index 70082d31..9b8a8eb6 100644 --- a/frontend/apps/web/src/app/app.tsx +++ b/frontend/apps/web/src/app/app.tsx @@ -13,7 +13,7 @@ import { AdapterLuxon } from "@mui/x-date-pickers/AdapterLuxon"; import * as React from "react"; import { ToastContainer } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; -import Loading from "../components/style/Loading"; +import { Loading } from "@/components/style"; import { api, ws } from "../core/api"; import { selectAuthSlice, selectSettingsSlice, selectTheme, useAppDispatch, useAppSelector } from "../store"; import { Router } from "./Router"; diff --git a/frontend/apps/web/src/app/authenticated-layout/SidebarGroupList.tsx b/frontend/apps/web/src/app/authenticated-layout/SidebarGroupList.tsx index 87be76b8..190bdb1b 100644 --- a/frontend/apps/web/src/app/authenticated-layout/SidebarGroupList.tsx +++ b/frontend/apps/web/src/app/authenticated-layout/SidebarGroupList.tsx @@ -1,5 +1,5 @@ -import GroupCreateModal from "@/components/groups/GroupCreateModal"; -import ListItemLink from "@/components/style/ListItemLink"; +import { GroupCreateModal } from "@/components/groups/GroupCreateModal"; +import { ListItemLink } from "@/components/style"; import { selectAuthSlice, selectGroupSlice, useAppSelector } from "@/store"; import { selectGroups, selectIsGuestUser } from "@abrechnung/redux"; import { Add } from "@mui/icons-material"; diff --git a/frontend/apps/web/src/components/ShareSelect.tsx b/frontend/apps/web/src/components/ShareSelect.tsx index ec8addb8..37bef20f 100644 --- a/frontend/apps/web/src/components/ShareSelect.tsx +++ b/frontend/apps/web/src/components/ShareSelect.tsx @@ -105,7 +105,7 @@ interface ShareSelectProps { groupId: number; label: string; value: TransactionShare; - onChange: (newShares: TransactionShare) => void; + onChange?: (newShares: TransactionShare) => void; error?: boolean | undefined; helperText?: React.ReactNode | undefined; shouldDisplayAccount?: (accountId: number) => boolean | undefined; @@ -204,10 +204,10 @@ export const ShareSelect: React.FC = ({ const newValue = { ...value }; if (shareValue === 0) { delete newValue[accountId]; - return onChange(newValue); + return onChange?.(newValue); } else { newValue[accountId] = shareValue; - return onChange(newValue); + return onChange?.(newValue); } }; diff --git a/frontend/apps/web/src/components/accounts/AccountClearingListEntry.tsx b/frontend/apps/web/src/components/accounts/AccountClearingListEntry.tsx index 93df5479..c6c1e2fa 100644 --- a/frontend/apps/web/src/components/accounts/AccountClearingListEntry.tsx +++ b/frontend/apps/web/src/components/accounts/AccountClearingListEntry.tsx @@ -5,8 +5,7 @@ import React from "react"; import { balanceColor } from "@/core/utils"; import { selectGroupSlice, useAppSelector } from "@/store"; import { getAccountLink } from "@/utils"; -import { ClearingAccountIcon } from "../style/AbrechnungIcons"; -import ListItemLink from "../style/ListItemLink"; +import { ListItemLink, ClearingAccountIcon } from "../style"; import { useTranslation } from "react-i18next"; import { useFormatCurrency } from "@/hooks"; import { ClearingAccount } from "@abrechnung/types"; diff --git a/frontend/apps/web/src/components/accounts/AccountTransactionListEntry.tsx b/frontend/apps/web/src/components/accounts/AccountTransactionListEntry.tsx index a4815810..09ff628d 100644 --- a/frontend/apps/web/src/components/accounts/AccountTransactionListEntry.tsx +++ b/frontend/apps/web/src/components/accounts/AccountTransactionListEntry.tsx @@ -5,8 +5,7 @@ import { DateTime } from "luxon"; import React from "react"; import { balanceColor } from "@/core/utils"; import { selectGroupSlice, selectTransactionSlice, useAppSelector } from "@/store"; -import { PurchaseIcon, TransferIcon } from "../style/AbrechnungIcons"; -import ListItemLink from "../style/ListItemLink"; +import { ListItemLink, PurchaseIcon, TransferIcon } from "../style"; import { useTranslation } from "react-i18next"; import { Transaction } from "@abrechnung/types"; diff --git a/frontend/apps/web/src/components/accounts/BalanceTable.tsx b/frontend/apps/web/src/components/accounts/BalanceTable.tsx index bcb19497..34b7c492 100644 --- a/frontend/apps/web/src/components/accounts/BalanceTable.tsx +++ b/frontend/apps/web/src/components/accounts/BalanceTable.tsx @@ -1,26 +1,26 @@ -import { selectAccountSlice, selectGroupSlice, useAppSelector } from "@/store"; -import { selectAccountBalances, selectGroupById, selectSortedAccounts } from "@abrechnung/redux"; +import { selectAccountSlice, useAppSelector } from "@/store"; +import { selectAccountBalances, selectSortedAccounts } from "@abrechnung/redux"; import { DataGrid, GridColDef, GridToolbar } from "@mui/x-data-grid"; import React from "react"; import { renderCurrency } from "../style/datagrid/renderCurrency"; import { useTranslation } from "react-i18next"; -import { Navigate } from "react-router-dom"; +import { Group } from "@abrechnung/api"; interface Props { - groupId: number; + group: Group; } -export const BalanceTable: React.FC = ({ groupId }) => { +export const BalanceTable: React.FC = ({ group }) => { const { t } = useTranslation(); const personalAccounts = useAppSelector((state) => - selectSortedAccounts({ state: selectAccountSlice(state), groupId, type: "personal", sortMode: "name" }) + selectSortedAccounts({ + state: selectAccountSlice(state), + groupId: group.id, + type: "personal", + sortMode: "name", + }) ); - const group = useAppSelector((state) => selectGroupById({ state: selectGroupSlice(state), groupId })); - const balances = useAppSelector((state) => selectAccountBalances({ state, groupId })); - - if (!group) { - return ; - } + const balances = useAppSelector((state) => selectAccountBalances({ state, groupId: group.id })); const tableData = personalAccounts.map((acc) => { return { diff --git a/frontend/apps/web/src/components/accounts/ClearingAccountDetail.tsx b/frontend/apps/web/src/components/accounts/ClearingAccountDetail.tsx index b725be03..90c61037 100644 --- a/frontend/apps/web/src/components/accounts/ClearingAccountDetail.tsx +++ b/frontend/apps/web/src/components/accounts/ClearingAccountDetail.tsx @@ -5,11 +5,11 @@ import { selectGroupSlice, useAppSelector } from "@/store"; import { ShareSelect } from "../ShareSelect"; import { useTranslation } from "react-i18next"; import { useFormatCurrency } from "@/hooks"; -import { Account } from "@abrechnung/types"; +import { ClearingAccount } from "@abrechnung/types"; interface Props { groupId: number; - account: Account; + account: ClearingAccount; } export const ClearingAccountDetail: React.FC = ({ groupId, account }) => { @@ -22,10 +22,6 @@ export const ClearingAccountDetail: React.FC = ({ groupId, account }) => if (!currency_symbol) { return null; } - if (account.type !== "clearing") { - throw new Error("expected a clearing account to render ClearingAccountDetail, but got a personal account"); - } - return ( <> {t("accounts.clearingDistributionOf", "", { account })} @@ -47,7 +43,6 @@ export const ClearingAccountDetail: React.FC = ({ groupId, account }) => )} )} - onChange={(value) => undefined} editable={false} /> diff --git a/frontend/apps/web/src/components/accounts/index.ts b/frontend/apps/web/src/components/accounts/index.ts new file mode 100644 index 00000000..f6af5a58 --- /dev/null +++ b/frontend/apps/web/src/components/accounts/index.ts @@ -0,0 +1,6 @@ +export * from "./AccountClearingListEntry"; +export * from "./AccountTransactionList"; +export * from "./DeleteAccountModal"; +export * from "./ClearingAccountDetail"; +export * from "./BalanceHistoryGraph"; +export * from "./BalanceTable"; diff --git a/frontend/apps/web/src/components/groups/GroupCreateModal.tsx b/frontend/apps/web/src/components/groups/GroupCreateModal.tsx index 600e1663..a00d7da7 100644 --- a/frontend/apps/web/src/components/groups/GroupCreateModal.tsx +++ b/frontend/apps/web/src/components/groups/GroupCreateModal.tsx @@ -137,5 +137,3 @@ export const GroupCreateModal: React.FC = ({ show, onClose }) => { ); }; - -export default GroupCreateModal; diff --git a/frontend/apps/web/src/components/groups/index.ts b/frontend/apps/web/src/components/groups/index.ts new file mode 100644 index 00000000..89d60ba7 --- /dev/null +++ b/frontend/apps/web/src/components/groups/index.ts @@ -0,0 +1,4 @@ +export * from "./InviteLinkCreate"; +export * from "./GroupCreateModal"; +export * from "./GroupDeleteModal"; +export * from "./GroupMemberSelect"; diff --git a/frontend/apps/web/src/components/index.ts b/frontend/apps/web/src/components/index.ts new file mode 100644 index 00000000..85e83efc --- /dev/null +++ b/frontend/apps/web/src/components/index.ts @@ -0,0 +1,7 @@ +export * from "./DateInput"; +export * from "./ShareSelect"; +export * from "./RequireAuth"; +export * from "./TagSelector"; +export * from "./AccountSelect"; +export * from "./TextInput"; +export * from "./NumericInput"; diff --git a/frontend/apps/web/src/components/style/EditableField.tsx b/frontend/apps/web/src/components/style/EditableField.tsx index b4c2e40a..49f3b6f3 100644 --- a/frontend/apps/web/src/components/style/EditableField.tsx +++ b/frontend/apps/web/src/components/style/EditableField.tsx @@ -93,5 +93,3 @@ export const EditableField: React.FC = ({ ); }; - -export default EditableField; diff --git a/frontend/apps/web/src/components/style/ListItemLink.tsx b/frontend/apps/web/src/components/style/ListItemLink.tsx index e115e51a..e3807226 100644 --- a/frontend/apps/web/src/components/style/ListItemLink.tsx +++ b/frontend/apps/web/src/components/style/ListItemLink.tsx @@ -10,10 +10,8 @@ type Props = { export const ListItemLink: React.FC = ({ to, children, selected = false, ...props }) => { return ( - + {children} ); }; - -export default ListItemLink; diff --git a/frontend/apps/web/src/components/style/Loading.tsx b/frontend/apps/web/src/components/style/Loading.tsx index 4e280908..7352ecd7 100644 --- a/frontend/apps/web/src/components/style/Loading.tsx +++ b/frontend/apps/web/src/components/style/Loading.tsx @@ -8,5 +8,3 @@ export const Loading: React.FC = () => { ); }; - -export default Loading; diff --git a/frontend/apps/web/src/components/style/mobile/index.tsx b/frontend/apps/web/src/components/style/MobilePaper.tsx similarity index 100% rename from frontend/apps/web/src/components/style/mobile/index.tsx rename to frontend/apps/web/src/components/style/MobilePaper.tsx diff --git a/frontend/apps/web/src/components/style/index.ts b/frontend/apps/web/src/components/style/index.ts new file mode 100644 index 00000000..622257ed --- /dev/null +++ b/frontend/apps/web/src/components/style/index.ts @@ -0,0 +1,7 @@ +export * from "./AbrechnungIcons"; +export * from "./ListItemLink"; +export * from "./Loading"; +export * from "./Search"; +export * from "./EditableField"; +export * from "./DisabledTextField"; +export * from "./MobilePaper"; diff --git a/frontend/apps/web/src/core/config.tsx b/frontend/apps/web/src/core/config.tsx index b90f28ac..6e6f2673 100644 --- a/frontend/apps/web/src/core/config.tsx +++ b/frontend/apps/web/src/core/config.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { z } from "zod"; import { environment } from "@/environments/environment"; import { AlertColor } from "@mui/material/Alert/Alert"; -import Loading from "@/components/style/Loading"; +import { Loading } from "@/components/style"; import { Alert, AlertTitle } from "@mui/material"; const configSchema = z.object({ diff --git a/frontend/apps/web/src/pages/accounts/AccountDetail/AccountDetail.tsx b/frontend/apps/web/src/pages/accounts/AccountDetail/AccountDetail.tsx index 45caf11d..0560779c 100644 --- a/frontend/apps/web/src/pages/accounts/AccountDetail/AccountDetail.tsx +++ b/frontend/apps/web/src/pages/accounts/AccountDetail/AccountDetail.tsx @@ -1,8 +1,7 @@ import { AccountTransactionList } from "@/components/accounts/AccountTransactionList"; import { BalanceHistoryGraph } from "@/components/accounts/BalanceHistoryGraph"; import { ClearingAccountDetail } from "@/components/accounts/ClearingAccountDetail"; -import { Loading } from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper, Loading } from "@/components/style"; import { useQuery, useTitle } from "@/core/utils"; import { selectAccountSlice, selectGroupSlice, useAppSelector } from "@/store"; import { selectAccountById, selectGroupById } from "@abrechnung/redux"; diff --git a/frontend/apps/web/src/pages/accounts/Balances.tsx b/frontend/apps/web/src/pages/accounts/Balances.tsx index 594255dd..192c0140 100644 --- a/frontend/apps/web/src/pages/accounts/Balances.tsx +++ b/frontend/apps/web/src/pages/accounts/Balances.tsx @@ -1,6 +1,5 @@ import { BalanceTable } from "@/components/accounts/BalanceTable"; -import { ListItemLink } from "@/components/style/ListItemLink"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper, ListItemLink } from "@/components/style"; import { useTitle } from "@/core/utils"; import { useFormatCurrency } from "@/hooks"; import { selectAccountSlice, selectGroupSlice, useAppSelector } from "@/store"; @@ -224,7 +223,7 @@ export const Balances: React.FC = ({ groupId }) => { )} - + diff --git a/frontend/apps/web/src/pages/accounts/ClearingAccountList/ClearingAccountList.tsx b/frontend/apps/web/src/pages/accounts/ClearingAccountList/ClearingAccountList.tsx index c9ee8d19..de62f716 100644 --- a/frontend/apps/web/src/pages/accounts/ClearingAccountList/ClearingAccountList.tsx +++ b/frontend/apps/web/src/pages/accounts/ClearingAccountList/ClearingAccountList.tsx @@ -25,7 +25,7 @@ import React, { useState } from "react"; import { Navigate, useNavigate } from "react-router-dom"; import { TagSelector } from "@/components/TagSelector"; import { DeleteAccountModal } from "@/components/accounts/DeleteAccountModal"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { useTitle } from "@/core/utils"; import { selectAccountSlice, selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; import { getAccountLink } from "@/utils"; diff --git a/frontend/apps/web/src/pages/accounts/PersonalAccountList/PersonalAccountList.tsx b/frontend/apps/web/src/pages/accounts/PersonalAccountList/PersonalAccountList.tsx index 738cc164..cda66d73 100644 --- a/frontend/apps/web/src/pages/accounts/PersonalAccountList/PersonalAccountList.tsx +++ b/frontend/apps/web/src/pages/accounts/PersonalAccountList/PersonalAccountList.tsx @@ -1,5 +1,5 @@ import { DeleteAccountModal } from "@/components/accounts/DeleteAccountModal"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { useTitle } from "@/core/utils"; import { selectAccountSlice, selectAuthSlice, selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; import { AccountSortMode } from "@abrechnung/core"; diff --git a/frontend/apps/web/src/pages/accounts/SettlementPlanDisplay.tsx b/frontend/apps/web/src/pages/accounts/SettlementPlanDisplay.tsx index 6e8c46ad..67c125f3 100644 --- a/frontend/apps/web/src/pages/accounts/SettlementPlanDisplay.tsx +++ b/frontend/apps/web/src/pages/accounts/SettlementPlanDisplay.tsx @@ -1,4 +1,4 @@ -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { selectAccountSlice, selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; import { SettlementPlanItem } from "@abrechnung/core"; import { diff --git a/frontend/apps/web/src/pages/auth/ConfirmRegistration.tsx b/frontend/apps/web/src/pages/auth/ConfirmRegistration.tsx index 01676562..56e4992c 100644 --- a/frontend/apps/web/src/pages/auth/ConfirmRegistration.tsx +++ b/frontend/apps/web/src/pages/auth/ConfirmRegistration.tsx @@ -2,7 +2,7 @@ import { Alert, Button, Container, Link, Typography } from "@mui/material"; import React, { useState } from "react"; import { Link as RouterLink, useParams } from "react-router-dom"; import { Loading } from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { api } from "@/core/api"; import { useTitle } from "@/core/utils"; import { Trans, useTranslation } from "react-i18next"; diff --git a/frontend/apps/web/src/pages/groups/Group.tsx b/frontend/apps/web/src/pages/groups/Group.tsx index bfa12436..84b0aca3 100644 --- a/frontend/apps/web/src/pages/groups/Group.tsx +++ b/frontend/apps/web/src/pages/groups/Group.tsx @@ -53,6 +53,12 @@ export const Group: React.FC = () => { dispatch(subscribe({ subscription: { type: "transaction", groupId }, websocket: ws })); dispatch(subscribe({ subscription: { type: "account", groupId }, websocket: ws })); dispatch(subscribe({ subscription: { type: "group_member", groupId }, websocket: ws })); + dispatch(fetchGroupDependencies({ groupId, api, fetchAnyway: true })) + .unwrap() + .catch((err: SerializedError) => { + console.warn(err); + toast.error(`Error while loading transactions and accounts: ${err.message}`); + }); return () => { dispatch(unsubscribe({ subscription: { type: "transaction", groupId }, websocket: ws })); @@ -61,17 +67,6 @@ export const Group: React.FC = () => { }; }, [dispatch, groupId, groupExists]); - React.useEffect(() => { - if (groupExists) { - dispatch(fetchGroupDependencies({ groupId, api, fetchAnyway: true })) - .unwrap() - .catch((err: SerializedError) => { - console.warn(err); - toast.error(`Error while loading transactions and accounts: ${err.message}`); - }); - } - }, [groupExists, groupId, dispatch]); - if (!groupExists) { console.error("did not find group, redirecting to 404"); return ; @@ -91,97 +86,22 @@ export const Group: React.FC = () => { // TODO: handle 404 return ( - - } /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - + }> + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + ); }; diff --git a/frontend/apps/web/src/pages/groups/GroupInvite.tsx b/frontend/apps/web/src/pages/groups/GroupInvite.tsx index 5bdae786..86765ce1 100644 --- a/frontend/apps/web/src/pages/groups/GroupInvite.tsx +++ b/frontend/apps/web/src/pages/groups/GroupInvite.tsx @@ -1,5 +1,4 @@ -import Loading from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper, Loading } from "@/components/style"; import { api } from "@/core/api"; import { useTitle } from "@/core/utils"; import { GroupPreview } from "@abrechnung/api"; diff --git a/frontend/apps/web/src/pages/groups/GroupInvites.tsx b/frontend/apps/web/src/pages/groups/GroupInvites.tsx index 3bce4683..be679bfe 100644 --- a/frontend/apps/web/src/pages/groups/GroupInvites.tsx +++ b/frontend/apps/web/src/pages/groups/GroupInvites.tsx @@ -26,7 +26,7 @@ import React, { useEffect, useState } from "react"; import { toast } from "react-toastify"; import { InviteLinkCreate } from "@/components/groups/InviteLinkCreate"; import { Loading } from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { api, ws } from "@/core/api"; import { useTitle } from "@/core/utils"; import { selectAuthSlice, selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; diff --git a/frontend/apps/web/src/pages/groups/GroupList.tsx b/frontend/apps/web/src/pages/groups/GroupList.tsx index fd3712ea..a6246796 100644 --- a/frontend/apps/web/src/pages/groups/GroupList.tsx +++ b/frontend/apps/web/src/pages/groups/GroupList.tsx @@ -1,7 +1,6 @@ import React, { useState } from "react"; -import ListItemLink from "@/components/style/ListItemLink"; -import GroupCreateModal from "@/components/groups/GroupCreateModal"; -import GroupDeleteModal from "@/components/groups/GroupDeleteModal"; +import { GroupCreateModal } from "@/components/groups/GroupCreateModal"; +import { GroupDeleteModal } from "@/components/groups/GroupDeleteModal"; import { Alert, Grid, @@ -13,7 +12,7 @@ import { Typography, } from "@mui/material"; import { Add, Delete } from "@mui/icons-material"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper, ListItemLink } from "@/components/style"; import { selectIsGuestUser, selectGroups } from "@abrechnung/redux"; import { useAppSelector, selectGroupSlice, selectAuthSlice } from "@/store"; import { useTitle } from "@/core/utils"; diff --git a/frontend/apps/web/src/pages/groups/GroupLog.tsx b/frontend/apps/web/src/pages/groups/GroupLog.tsx index a6b13ac0..ac9cab58 100644 --- a/frontend/apps/web/src/pages/groups/GroupLog.tsx +++ b/frontend/apps/web/src/pages/groups/GroupLog.tsx @@ -22,7 +22,7 @@ import { DateTime } from "luxon"; import React, { useEffect, useState } from "react"; import { toast } from "react-toastify"; import { Loading } from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { api, ws } from "@/core/api"; import { useTitle } from "@/core/utils"; import { selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; diff --git a/frontend/apps/web/src/pages/groups/GroupMemberList.tsx b/frontend/apps/web/src/pages/groups/GroupMemberList.tsx index 0ca98c6e..224917dd 100644 --- a/frontend/apps/web/src/pages/groups/GroupMemberList.tsx +++ b/frontend/apps/web/src/pages/groups/GroupMemberList.tsx @@ -27,7 +27,7 @@ import { Form, Formik, FormikHelpers } from "formik"; import { DateTime } from "luxon"; import React, { useState } from "react"; import { toast } from "react-toastify"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { api } from "@/core/api"; import { useTitle } from "@/core/utils"; import { selectAuthSlice, selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; diff --git a/frontend/apps/web/src/pages/groups/GroupSettings.tsx b/frontend/apps/web/src/pages/groups/GroupSettings.tsx index c94a2f67..13475d3b 100644 --- a/frontend/apps/web/src/pages/groups/GroupSettings.tsx +++ b/frontend/apps/web/src/pages/groups/GroupSettings.tsx @@ -19,7 +19,7 @@ import { Navigate, useNavigate } from "react-router-dom"; import { toast } from "react-toastify"; import { z } from "zod"; import { DisabledFormControlLabel, DisabledTextField } from "@/components/style/DisabledTextField"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { api } from "@/core/api"; import { useTitle } from "@/core/utils"; import { selectGroupSlice, useAppDispatch, useAppSelector } from "@/store"; diff --git a/frontend/apps/web/src/pages/profile/ChangeEmail.tsx b/frontend/apps/web/src/pages/profile/ChangeEmail.tsx index cfc3c529..3f6e31c1 100644 --- a/frontend/apps/web/src/pages/profile/ChangeEmail.tsx +++ b/frontend/apps/web/src/pages/profile/ChangeEmail.tsx @@ -5,7 +5,7 @@ import React from "react"; import { useTranslation } from "react-i18next"; import { toast } from "react-toastify"; import { z } from "zod"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { api } from "@/core/api"; import { useTitle } from "@/core/utils"; diff --git a/frontend/apps/web/src/pages/profile/ChangePassword.tsx b/frontend/apps/web/src/pages/profile/ChangePassword.tsx index 71fd1a19..686873a1 100644 --- a/frontend/apps/web/src/pages/profile/ChangePassword.tsx +++ b/frontend/apps/web/src/pages/profile/ChangePassword.tsx @@ -5,7 +5,7 @@ import React from "react"; import { useTranslation } from "react-i18next"; import { toast } from "react-toastify"; import { z } from "zod"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { api } from "@/core/api"; import { useTitle } from "@/core/utils"; import i18n from "@/i18n"; diff --git a/frontend/apps/web/src/pages/profile/Profile.tsx b/frontend/apps/web/src/pages/profile/Profile.tsx index 102be4a3..166a5bf2 100644 --- a/frontend/apps/web/src/pages/profile/Profile.tsx +++ b/frontend/apps/web/src/pages/profile/Profile.tsx @@ -1,5 +1,4 @@ -import Loading from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper, Loading } from "@/components/style"; import { useTitle } from "@/core/utils"; import { selectAuthSlice, useAppSelector } from "@/store"; import { selectProfile } from "@abrechnung/redux"; diff --git a/frontend/apps/web/src/pages/profile/SessionList.tsx b/frontend/apps/web/src/pages/profile/SessionList.tsx index 901d1301..d7b3d115 100644 --- a/frontend/apps/web/src/pages/profile/SessionList.tsx +++ b/frontend/apps/web/src/pages/profile/SessionList.tsx @@ -18,8 +18,7 @@ import { import { DateTime } from "luxon"; import React, { useState } from "react"; import { toast } from "react-toastify"; -import Loading from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper, Loading } from "@/components/style"; import { api } from "@/core/api"; import { useTitle } from "@/core/utils"; import { selectAuthSlice, useAppSelector } from "@/store"; diff --git a/frontend/apps/web/src/pages/profile/Settings.tsx b/frontend/apps/web/src/pages/profile/Settings.tsx index 81e03c2b..5e090129 100644 --- a/frontend/apps/web/src/pages/profile/Settings.tsx +++ b/frontend/apps/web/src/pages/profile/Settings.tsx @@ -1,4 +1,4 @@ -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { useTitle } from "@/core/utils"; import { ThemeMode, diff --git a/frontend/apps/web/src/pages/transactions/TransactionDetail/FileGallery.tsx b/frontend/apps/web/src/pages/transactions/TransactionDetail/FileGallery.tsx index 2f1bc4c3..8a97993b 100644 --- a/frontend/apps/web/src/pages/transactions/TransactionDetail/FileGallery.tsx +++ b/frontend/apps/web/src/pages/transactions/TransactionDetail/FileGallery.tsx @@ -1,4 +1,4 @@ -import Loading from "@/components/style/Loading"; +import { Loading } from "@/components/style"; import { api } from "@/core/api"; import { selectTransactionSlice, useAppDispatch, useAppSelector } from "@/store"; import { FileAttachment as BackendFileAttachment, NewFile } from "@abrechnung/api"; diff --git a/frontend/apps/web/src/pages/transactions/TransactionDetail/TransactionDetail.tsx b/frontend/apps/web/src/pages/transactions/TransactionDetail/TransactionDetail.tsx index 2e8f80b7..54b03e61 100644 --- a/frontend/apps/web/src/pages/transactions/TransactionDetail/TransactionDetail.tsx +++ b/frontend/apps/web/src/pages/transactions/TransactionDetail/TransactionDetail.tsx @@ -1,5 +1,4 @@ -import Loading from "@/components/style/Loading"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper, Loading } from "@/components/style"; import { api } from "@/core/api"; import { useQuery, useTitle } from "@/core/utils"; import { selectGroupSlice, selectTransactionSlice, useAppDispatch, useAppSelector } from "@/store"; diff --git a/frontend/apps/web/src/pages/transactions/TransactionDetail/purchase/TransactionPositions.tsx b/frontend/apps/web/src/pages/transactions/TransactionDetail/purchase/TransactionPositions.tsx index babd4277..d9296b10 100644 --- a/frontend/apps/web/src/pages/transactions/TransactionDetail/purchase/TransactionPositions.tsx +++ b/frontend/apps/web/src/pages/transactions/TransactionDetail/purchase/TransactionPositions.tsx @@ -1,5 +1,5 @@ import { AccountSelect } from "@/components/AccountSelect"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { useFormatCurrency } from "@/hooks"; import { selectAccountSlice, selectTransactionSlice, useAppDispatch, useAppSelector } from "@/store"; import { getAccountSortFunc } from "@abrechnung/core"; diff --git a/frontend/apps/web/src/pages/transactions/TransactionList/TransactionList.tsx b/frontend/apps/web/src/pages/transactions/TransactionList/TransactionList.tsx index a1ffa85a..6701576d 100644 --- a/frontend/apps/web/src/pages/transactions/TransactionList/TransactionList.tsx +++ b/frontend/apps/web/src/pages/transactions/TransactionList/TransactionList.tsx @@ -36,7 +36,7 @@ import React, { useState } from "react"; import { Navigate, useNavigate } from "react-router-dom"; import { TagSelector } from "@/components/TagSelector"; import { PurchaseIcon, TransferIcon } from "@/components/style/AbrechnungIcons"; -import { MobilePaper } from "@/components/style/mobile"; +import { MobilePaper } from "@/components/style"; import { useTitle } from "@/core/utils"; import { selectGroupSlice, useAppDispatch, useAppSelector, selectAccountSlice, selectTransactionSlice } from "@/store"; import { TransactionListItem } from "./TransactionListItem";