diff --git a/src/app/LoadingScreen.tsx b/src/app/LoadingScreen.tsx index ae808b8..7ba258a 100644 --- a/src/app/LoadingScreen.tsx +++ b/src/app/LoadingScreen.tsx @@ -1,4 +1,4 @@ -import { CircularProgress, Typography, useTheme } from "@mui/material"; +import { Box, CircularProgress, Typography, useTheme } from "@mui/material"; interface Props { message?: string; @@ -9,7 +9,7 @@ export default function LoadingScreen(props: Props) { const theme = useTheme(); return ( - <> + {message ? message : "Loading..."} - + ); } \ No newline at end of file diff --git a/src/common/ResponsiveTable.tsx b/src/common/ResponsiveTable.tsx index debe1fa..246e98d 100644 --- a/src/common/ResponsiveTable.tsx +++ b/src/common/ResponsiveTable.tsx @@ -22,6 +22,10 @@ const useStyles = makeStyles((theme: Theme) => { title: { padding: theme.spacing(1) }, + subtitle: { + padding: theme.spacing(1), + marginTop: theme.spacing(-2), + }, titleContainer: { border: "none", }, @@ -51,6 +55,7 @@ interface Props { rows: T[], columns?: Column[], title?: string | JSX.Element; + subtitle?: string | JSX.Element; total: number, pageSize: number, page: number, @@ -75,6 +80,7 @@ export default function ResponsiveTable(props: Props) { setPage, handleRowsPerPageChange, title, + subtitle, renderGutter, setSearchText, isLoading, @@ -177,6 +183,20 @@ export default function ResponsiveTable(props: Props) { return null } + const renderSubtitle = () => { + if (typeof(subtitle) === "string" ) return ( + + {subtitle} + + ) + if (subtitle) return ( + + {subtitle} haha lol + + ) + return null + } + function capitalize(val: any) { return String(val).charAt(0).toUpperCase() + String(val).slice(1); } @@ -231,6 +251,7 @@ export default function ResponsiveTable(props: Props) { {renderTitle()} + {renderSubtitle()} {setSearchText && searchBar()} {rows.map((row, index) => { @@ -290,15 +311,10 @@ export default function ResponsiveTable(props: Props) { - {typeof(title) === "string" ? - - {title} - - : - title && - {title} + + {renderTitle()} + {renderSubtitle()} - } {setSearchText && @@ -308,7 +324,7 @@ export default function ResponsiveTable(props: Props) { - { !hideKeys && + { renderGutter && } { columns ? columns.map((column, index) => { @@ -327,7 +343,7 @@ export default function ResponsiveTable(props: Props) { ) }) } - } + { isLoading ? diff --git a/src/navigation/Router.tsx b/src/navigation/Router.tsx index 2407c0c..d4b7849 100644 --- a/src/navigation/Router.tsx +++ b/src/navigation/Router.tsx @@ -8,6 +8,7 @@ import SideNavigator from "./SideNavigator"; import Users from "pages/Users"; import { useMobile } from "hooks"; import BottomNavigator from "./BottomNavigator"; +import TeamPage from "pages/Team"; interface Props { open: boolean, @@ -52,10 +53,12 @@ export default function Router(props: Props) { {/* Redirects */} } /> + } /> {/* Page routes */} } /> + } /> } /> {/* ({ interface Props extends PropsWithChildren{ fullViewport?: boolean; isCenterCenter?: boolean; + sx?: SxProps; } export const PageContainer: React.FunctionComponent = props => { const classes = useStyles(); - const { children, fullViewport, isCenterCenter } = props; + const { children, fullViewport, isCenterCenter, sx } = props; // let fullViewport = false // let isCenterCenter = false return ( @@ -50,6 +51,7 @@ export const PageContainer: React.FunctionComponent = props => { fullViewport ? classes.fullViewportContainer : classes.pageContainer, isCenterCenter && classes.centerCenter )} + sx={sx} disableGutters maxWidth={false} children={{children}} diff --git a/src/teams/TeamList.tsx b/src/teams/TeamList.tsx index 3356087..50a6b7a 100644 --- a/src/teams/TeamList.tsx +++ b/src/teams/TeamList.tsx @@ -11,7 +11,7 @@ import { IconButton, } from "@mui/material"; import { pond } from "protobuf-ts/pond"; -import { useGlobalState, useTeamAPI, useUserAPI } from "providers"; +import { useGlobalState, useSnackbar, useTeamAPI, useUserAPI } from "providers"; import { Team, teamScope } from "models"; import { useNavigate } from "react-router"; import { cloneDeep } from "lodash"; @@ -57,6 +57,7 @@ export default function TeamList() { const userAPI = useUserAPI(); const history = useNavigate(); const isMobile = useMobile() + const snackbar = useSnackbar(); const [{ user, as }] = useGlobalState(); const [teamPerms, setTeamPerms] = useState>(new Map()); const [teamPrefs, setTeamPrefs] = useState >(new Map()); @@ -91,13 +92,17 @@ export default function TeamList() { .then(resp => { newTeamPerms.set(t.key(), resp.permissions) newTeamPrefs.set(t.key(), resp.preferences) + t.preferences = cloneDeep(resp.preferences) + t.permissions = cloneDeep(resp.permissions) + }).catch(() => { + snackbar.error("Error loading teams.") }) .finally(() => { setTeamPerms(newTeamPerms); setTeamPrefs(newTeamPrefs); }); } - newTeams.push(Team.create(team)) + newTeams.push(t) }); setTeams(newTeams); }) @@ -158,7 +163,7 @@ export default function TeamList() { > { - if (team.settings) history(team.settings.key); + if (team.settings) history(team.settings.key, { state: {team: team} }); }} > diff --git a/src/user/UserAvatar.tsx b/src/user/UserAvatar.tsx index 45a23fb..0b39d7f 100644 --- a/src/user/UserAvatar.tsx +++ b/src/user/UserAvatar.tsx @@ -1,4 +1,4 @@ -import { Avatar } from "@mui/material"; +import { Avatar, SxProps, Theme, useTheme } from "@mui/material"; import { Team, User } from "models"; import React from "react"; @@ -40,18 +40,34 @@ interface Props { user: User | Team; className?: string; style?: React.CSSProperties; + sx?: SxProps; + size?: "small" | "medium" | "large"; } -export default function UserSettings(props: Props) { - const { user, className, style } = props; +export default function UserAvatar(props: Props) { + const theme = useTheme() + const { user, className, style, sx, size } = props; + + const getSize = () => { + if (size==="large") return theme.spacing(8) + if (size==="medium") return theme.spacing(6) + if (size==="small") return theme.spacing(4) + return undefined + } return ( ); } diff --git a/src/user/UserSettings.tsx b/src/user/UserSettings.tsx index 99aa844..9c884c3 100644 --- a/src/user/UserSettings.tsx +++ b/src/user/UserSettings.tsx @@ -131,7 +131,6 @@ export default function UserSettings(props: Props) { const changeTimezone = (tz: string) => { let updatedUser = User.clone(user); updatedUser.settings.timezone = tz; - setUser(updatedUser); }; @@ -183,7 +182,6 @@ export default function UserSettings(props: Props) { -