diff --git a/Website/src/activitys/DescriptonActivity.tsx b/Website/src/activitys/DescriptonActivity.tsx index 30d83817..7a648e39 100644 --- a/Website/src/activitys/DescriptonActivity.tsx +++ b/Website/src/activitys/DescriptonActivity.tsx @@ -4,32 +4,8 @@ import { useActivity } from "@Hooks/useActivity"; import React from "react"; import { Toolbar } from "@Components/onsenui/Toolbar"; import { Page } from "@Components/onsenui/Page"; -import { StyledCard } from "@Components/StyledCard"; -import Stack from "@mui/material/Stack"; -import { Alert, AlertTitle, Avatar, Box, Button, CardMedia, Paper, SxProps, Theme, Typography } from "@mui/material"; -import { CommentsActivity } from "./CommentsActivity"; -import { os } from "@Native/Os"; import { useStrings } from "@Hooks/useStrings"; - -import SecurityIcon from "@mui/icons-material/Security"; -import BugReportIcon from "@mui/icons-material/BugReport"; -import LocalPoliceIcon from "@mui/icons-material/LocalPolice"; -import { colors } from "@Hooks/useSettings"; - -import ArrowBackIcon from "@mui/icons-material/ArrowBack"; -import VerifiedIcon from "@mui/icons-material/Verified"; -import CommentIcon from "@mui/icons-material/Comment"; -import FileDownloadIcon from "@mui/icons-material/FileDownload"; -import DeviceUnknownIcon from "@mui/icons-material/DeviceUnknown"; -import ModuleFilterConfActivity from "./ModuleFilterConfActivity"; -import { parseAndroidVersion } from "@Util/parseAndroidVersion"; import { useTheme } from "@Hooks/useTheme"; -import { StyledIconButtonWithText } from "@Components/StyledIconButton"; -import { useModuleOptions } from "@Hooks/useModuleOptions"; -import { useSupportIconForUrl } from "@Hooks/useSupportIconForUrl"; -import TerminalActivity from "./TerminalActivity"; -import { BottomToolbar } from "@Components/onsenui/BottomToolbar"; -import ProfileActivty from "./account/ProfileActivity"; type Extra = { title: string; @@ -46,30 +22,15 @@ interface State { data?: T; error?: Error; } + type Cache = { [url: string]: T }; type Action = { type: "loading" } | { type: "fetched"; payload: T } | { type: "error"; payload: Error }; -const badgeStyle: (color: (typeof colors)["blue" | "teal" | "red" | "orange"]) => SxProps = (color) => { - return { - px: 1, - py: 0.5, - borderRadius: 1, - display: "flex", - typography: "caption", - bgcolor: (theme) => (theme.palette.mode === "dark" ? color[900] : color[50]), - color: (theme) => (theme.palette.mode === "dark" ? "#fff" : color[700]), - }; -}; - function DescriptonActivity() { const { context, extra } = useActivity(); const { strings } = useStrings(); const { theme } = useTheme(); - const { desc, title, request, prop_url, zip_url, module_options, authorData } = extra; - - const { isVerified, isHidden } = useModuleOptions(prop_url?.id); - - const SupportIcon = useSupportIconForUrl(prop_url?.support); + const { desc, title, request } = extra; const initialState: State = { error: undefined, @@ -148,7 +109,7 @@ function DescriptonActivity() { return ( - + {title} @@ -156,49 +117,7 @@ function DescriptonActivity() { }; return ( - { - return zip_url ? ( - - - - {/* {os.isAndroid && ( - - )} */} - - - ) : null; - }} - > + {!state.data ? ( ) : ( <> - {prop_url && ( - - - - {!(prop_url.mmrlNoComments === "true") && ( - { - context.pushPage({ - component: CommentsActivity, - key: "comments_" + prop_url.id, - extra: { - id: prop_url.id, - }, - }); - }} - > - - - - - )} - - {isVerified && ( - - - - {strings.verified} - - - )} - - { - context.pushPage({ - component: ModuleFilterConfActivity, - key: "comments_" + prop_url.id, - extra: { - prop_url: prop_url, - }, - }); - }} - > - - - Specs - - - - {prop_url.support && ( - { - os.open(prop_url.support, { - target: "_blank", - features: { - color: theme.palette.primary.main, - }, - }); - }} - > - - {/* */} - Support - - - )} - - - {prop_url.minApi && os.sdk <= Number(prop_url.minApi) && ( - - Unsupported - Module requires {parseAndroidVersion(prop_url.minApi)} - - )} - - {/* User info */} - {authorData && ( - { - context.pushPage({ - component: ProfileActivty, - key: "", - extra: { - uid: prop_url.mmrlAuthor, - }, - }); - }} - elevation={0} - sx={{ - ":hover": { - cursor: "pointer", - }, - width: "100%", - display: "flex", - p: 1, - flexDirection: { - // xs: "column", // mobile - xs: "row", // mobile - sm: "row", // tablet and up - }, - }} - > - - - - {authorData.username} - - - {authorData?.options?.roles?.verified && ( - - - Verified - - )} - {authorData?.options?.roles?.mod && ( - - - MMRL Moderator - - )} - {authorData?.options?.roles?.admin && ( - - - MMRL Admin - - )} - {authorData?.options?.roles?.bughunter && ( - - - Bug Hunter - - )} - - - - )} - - - )} - {/* - - - {authorData.username} - {authorData.options?.verified && } - - */} - )} diff --git a/Website/src/activitys/RepoActivity/components/LocalRepository.tsx b/Website/src/activitys/RepoActivity/components/LocalRepository.tsx index 2b10b8dd..6731ce3b 100644 --- a/Website/src/activitys/RepoActivity/components/LocalRepository.tsx +++ b/Website/src/activitys/RepoActivity/components/LocalRepository.tsx @@ -38,8 +38,6 @@ import ons from "onsenui"; import { StyledIconButton, StyledIconButtonWithText } from "@Components/StyledIconButton"; import { StyledCard } from "@Components/StyledCard"; import { useFormatDate } from "@Hooks/useFormatDate"; -import { ref, onValue, query } from "firebase/database"; -import { useFirebase } from "@Hooks/useFirebase"; import { useConfirm } from "material-ui-confirm"; import { useTheme } from "@Hooks/useTheme"; import CloseIcon from "@mui/icons-material/Close"; @@ -61,7 +59,6 @@ export const LocalRepository = (props: LocalRepositoryProps) => { const { strings } = useStrings(); const { settings, setSettings } = useSettings(); const confirm = useConfirm(); - const { auth, firebaseVoid } = useFirebase(); const { actions } = useRepos(); const [enabled, setEnabled] = React.useState(!settings.disabled_repos.includes(repo.id)); const { theme, scheme } = useTheme(); @@ -86,21 +83,6 @@ export const LocalRepository = (props: LocalRepositoryProps) => { const [authorData, setAuthorData] = React.useState({}); - React.useEffect(() => { - console.log(repo); - if (repo?.mmrlOwner) { - firebaseVoid((auth, db) => { - const dbRef = ref(db, "users/" + repo.mmrlOwner); - onValue(query(dbRef), (snapshot) => { - setAuthorData(snapshot.val()); - console.log(snapshot.val()); - }); - }); - } else { - setAuthorData(undefined); - } - }, []); - const [open, setOpen] = React.useState(false); const handleClickOpen = () => { @@ -124,8 +106,7 @@ export const LocalRepository = (props: LocalRepositoryProps) => { {repo.name} {" "} - {repo.mmrlOwner ? {authorData.username ? authorData.username : "Unknown owner"} : Unknown owner} - {authorData?.options?.roles?.verified && } + Unknown owner {formatLastUpdate} diff --git a/Website/src/activitys/account/AccountActivity.tsx b/Website/src/activitys/account/AccountActivity.tsx deleted file mode 100644 index 10d785a3..00000000 --- a/Website/src/activitys/account/AccountActivity.tsx +++ /dev/null @@ -1,417 +0,0 @@ -import { useActivity } from "@Hooks/useActivity"; -import { Toolbar } from "@Components/onsenui/Toolbar"; -import { Page } from "@Components/onsenui/Page"; -import { useStrings } from "@Hooks/useStrings"; -import Stack from "@mui/material/Stack"; -import { set, ref, update, onValue, get, query } from "firebase/database"; -import { signOut, sendEmailVerification } from "firebase/auth"; -import EditIcon from "@mui/icons-material/Edit"; -import PersonIcon from "@mui/icons-material/Person"; -import AlternateEmailIcon from "@mui/icons-material/AlternateEmail"; -import PasswordIcon from "@mui/icons-material/Password"; -import SaveIcon from "@mui/icons-material/Save"; -import VerifiedIcon from "@mui/icons-material/Verified"; -import ExitToAppIcon from "@mui/icons-material/ExitToApp"; -import ViewModuleIcon from "@mui/icons-material/ViewModule"; -import React from "react"; -import TextField from "@mui/material/TextField"; -import FormControl from "@mui/material/FormControl"; -import OutlinedInput from "@mui/material/OutlinedInput"; -import InputLabel from "@mui/material/InputLabel"; -import InputAdornment from "@mui/material/InputAdornment"; -import IconButton from "@mui/material/IconButton"; -import Grid from "@mui/material/Grid"; -import Avatar from "@mui/material/Avatar"; -import { os } from "@Native/Os"; -import Alert from "@mui/material/Alert"; -import AlertTitle from "@mui/material/AlertTitle"; -import { - CardMedia, - Box, - Typography, - Card, - SxProps, - Theme, - Paper, - List, - ListItem, - ListItemText, - CardContent, - Button, - ListSubheader, - ListItemIcon, - ListItemButton, -} from "@mui/material"; -import { useTheme } from "@Hooks/useTheme"; - -import SecurityIcon from "@mui/icons-material/Security"; -import BugReportIcon from "@mui/icons-material/BugReport"; -import LocalPoliceIcon from "@mui/icons-material/LocalPolice"; -import { colors } from "@Hooks/useSettings"; -import { useFormatDate } from "@Hooks/useFormatDate"; -import { useRepos } from "@Hooks/useRepos"; -import { ExploreModule } from "@Components/ExploreModule"; -import { CustomTextField } from "@Components/TextField"; -import { useFirebase } from "@Hooks/useFirebase"; -import ProfileDetailsActivity from "./ProfileDetailsActivity"; -import ChangeEmailActivity from "./ChangeEmailActivity"; -import ExploreModuleFragment, { ExploreModuleProps } from "@Activitys/fragments/ExploreModuleFragment"; - -const badgeStyle: (color: (typeof colors)["blue" | "teal" | "red" | "orange"]) => SxProps = (color) => { - return { - px: 1, - py: 0.5, - borderRadius: 1, - display: "flex", - typography: "caption", - bgcolor: (theme) => (theme.palette.mode === "dark" ? color[900] : color[50]), - color: (theme) => (theme.palette.mode === "dark" ? "#fff" : color[700]), - }; -}; - -const AccountActivty = () => { - const { strings } = useStrings(); - const { context, extra } = useActivity(); - const { auth, firebaseVoid } = useFirebase(); - - const [username, setUsername] = React.useState(""); - const [picurl, setPicurl] = React.useState(""); - const [bio, setBio] = React.useState(""); - const [options, setOptions] = React.useState({}); - - React.useEffect(() => { - firebaseVoid((auth, db) => { - const dbRef = ref(db, "users/" + auth.currentUser?.uid); - onValue(query(dbRef), (snapshot) => { - const snap = snapshot.val(); - setUsername(snap.username); - setBio(snap.bio); - setPicurl(snap.picurl); - console.log(snap.options); - setOptions(snap.options); - }); - }); - }, []); - - const renderToolbar = () => { - return ( - - - - - Account - - { - firebaseVoid((auth) => { - signOut(auth) - .then(() => { - context.popPage(); - }) - .catch((error) => { - os.toast(error, Toast.LENGTH_SHORT); - }); - }); - }} - /> - - - ); - }; - - return ( - - - - - - - - - {username} - - - {options?.roles?.verified && ( - - - Verified - - )} - {options?.roles?.mod && ( - - - MMRL Moderator - - )} - {options?.roles?.admin && ( - - - MMRL Admin - - )} - {options?.roles?.bughunter && ( - - - Bug Hunter - - )} - - - - - {!auth?.currentUser?.emailVerified && ( - { - firebaseVoid((auth) => { - sendEmailVerification(auth.currentUser as any) - .then(() => { - os.toast("E-Mail has been sent", Toast.LENGTH_SHORT); - }) - .catch((error) => { - os.toast(error.message, Toast.LENGTH_SHORT); - }); - }); - }} - color="inherit" - size="small" - > - VERIFY - - } - > - Your email haven't been verified yet. You won't able to edit your profile information - - )} - - - {"Account"}}> - - { - context.pushPage({ - component: ProfileDetailsActivity, - key: "profile_details_1", - extra: { - username: username, - picurl: picurl, - bio: bio, - options: options, - }, - }); - }} - > - - - - - - - - { - context.pushPage<{}, ExploreModuleProps>({ - component: ExploreModuleFragment, - key: "participating_modules_3", - props: { - renderToolbar: (ref, ctx) => ( - - - - - Participating - - ), - applyFilter: (modules, search) => - modules - .filter((m) => m.prop_url?.mmrlAuthor?.includes(auth?.currentUser?.uid as any)) - .filter( - (module) => - module.prop_url.id.toLowerCase().includes(search.toLowerCase()) || - module.prop_url.name.toLowerCase().includes(search.toLowerCase()) || - module.prop_url.author.toLowerCase().includes(search.toLowerCase()) || - module.prop_url.description.toLowerCase().includes(search.toLowerCase()) - ), - }, - }); - }} - > - - - - - - - - - {"Account"}}> - - { - // context.pushPage({ - // component: ChangeEmailActivity, - // props: { - // key: "change_email_0", - // extra: {}, - // }, - // }); - }} - > - - - - - Change email Soon - - } - /> - - - - - - - - - - Reset password Soon - - } - /> - - - - - {/* - - - - - Picture URL - { - setPicurl(event.target.value); - }} - value={picurl} - id="outlined-adornment-picurl" - endAdornment={ - - - {editPicurl ? ( - { - firebaseVoid((auth, db) => { - update(ref(db, `users/${auth.currentUser?.uid}`), { - picurl: picurl, - }); - }); - }} - /> - ) : ( - - )} - - - } - label="Picture URL" - /> - - - - - - - - - - - - Participating - - - - - - {filteredModules.map((module, i) => ( - - - - ))} - - */} - - - - ); -}; - -export default AccountActivty; diff --git a/Website/src/activitys/account/ChangeEmailActivity.tsx b/Website/src/activitys/account/ChangeEmailActivity.tsx deleted file mode 100644 index d9593907..00000000 --- a/Website/src/activitys/account/ChangeEmailActivity.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { Menu } from "@mui/icons-material"; -import { useActivity } from "@Hooks/useActivity"; -import { Toolbar } from "@Components/onsenui/Toolbar"; -import { os } from "@Native/Os"; -import { Page } from "@Components/onsenui/Page"; -import { useStrings } from "@Hooks/useStrings"; -import { Tabbar, TabbarRenderTab } from "@Components/onsenui/Tabbar"; -import Register from "./fragments/Register"; -import Login from "./fragments/Login"; -import Paper from "@mui/material/Paper"; -import { CustomTextField } from "@Components/TextField"; -import React from "react"; -import { set, ref, update, onValue, get, query } from "firebase/database"; -import { updateEmail } from "firebase/auth"; -import { useFirebase } from "@Hooks/useFirebase"; -import Button from "@mui/material/Button"; -import Card from "@mui/material/Card"; - -const ChangeEmailActivity = () => { - const { strings } = useStrings(); - const { context } = useActivity(); - const { auth, firebaseVoid } = useFirebase(); - - const [email, setEmail] = React.useState(""); - const [currentEmail] = React.useState(auth?.currentUser?.email); - - const renderToolbar = () => { - return ( - - - - - Change email - - ); - }; - - const handleSaveChanges = () => { - firebaseVoid((auth, db) => { - if (auth.currentUser) { - updateEmail(auth.currentUser, email) - .then(() => { - os.toast("Email has been updated successfully", Toast.LENGTH_SHORT); - }) - .catch((error) => { - os.toast(error, Toast.LENGTH_SHORT); - }); - } else { - os.toast("Current user is null", Toast.LENGTH_SHORT); - } - }); - }; - - return ( - - - -
- - { - setEmail(event.target.value); - }} - type="email" - value={email} - label="Email" - variant="outlined" - /> -
- - -
-
-
- ); -}; - -export default ChangeEmailActivity; diff --git a/Website/src/activitys/account/NoAccountActivity.tsx b/Website/src/activitys/account/NoAccountActivity.tsx deleted file mode 100644 index 665e4dfa..00000000 --- a/Website/src/activitys/account/NoAccountActivity.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { Menu } from "@mui/icons-material"; -import { useActivity } from "@Hooks/useActivity"; -import { Toolbar } from "@Components/onsenui/Toolbar"; -import { os } from "@Native/Os"; -import { Page } from "@Components/onsenui/Page"; -import { useStrings } from "@Hooks/useStrings"; -import { Tabbar, TabbarRenderTab } from "@Components/onsenui/Tabbar"; -import Register from "./fragments/Register"; -import Login from "./fragments/Login"; - -const NoAccountActivty = () => { - const { strings } = useStrings(); - const { context } = useActivity(); - - const renderTabs = (): TabbarRenderTab[] => { - return [ - { - content: , - tab: , - }, - { - content: , - tab: , - }, - ]; - }; - - const renderToolbar = () => { - return ( - - - - - Account - - ); - }; - - return ( - - - - ); -}; - -export default NoAccountActivty; diff --git a/Website/src/activitys/account/ProfileActivity.tsx b/Website/src/activitys/account/ProfileActivity.tsx deleted file mode 100644 index b0b655bc..00000000 --- a/Website/src/activitys/account/ProfileActivity.tsx +++ /dev/null @@ -1,233 +0,0 @@ -import { useActivity } from "@Hooks/useActivity"; -import { Toolbar } from "@Components/onsenui/Toolbar"; -import { Page } from "@Components/onsenui/Page"; -import { useStrings } from "@Hooks/useStrings"; -import Stack from "@mui/material/Stack"; -import { set, ref, update, onValue, get, query } from "firebase/database"; -import { signOut, sendEmailVerification } from "firebase/auth"; -import EditIcon from "@mui/icons-material/Edit"; -import PersonIcon from "@mui/icons-material/Person"; -import AlternateEmailIcon from "@mui/icons-material/AlternateEmail"; -import PasswordIcon from "@mui/icons-material/Password"; -import SaveIcon from "@mui/icons-material/Save"; -import VerifiedIcon from "@mui/icons-material/Verified"; -import ExitToAppIcon from "@mui/icons-material/ExitToApp"; -import ViewModuleIcon from "@mui/icons-material/ViewModule"; -import React from "react"; -import TextField from "@mui/material/TextField"; -import FormControl from "@mui/material/FormControl"; -import OutlinedInput from "@mui/material/OutlinedInput"; -import InputLabel from "@mui/material/InputLabel"; -import InputAdornment from "@mui/material/InputAdornment"; -import IconButton from "@mui/material/IconButton"; -import Grid from "@mui/material/Grid"; -import Avatar from "@mui/material/Avatar"; -import { os } from "@Native/Os"; -import Alert from "@mui/material/Alert"; -import AlertTitle from "@mui/material/AlertTitle"; -import { - CardMedia, - Box, - Typography, - Card, - SxProps, - Theme, - Paper, - List, - ListItem, - ListItemText, - CardContent, - Button, - ListSubheader, - ListItemIcon, - ListItemButton, -} from "@mui/material"; -import { useTheme } from "@Hooks/useTheme"; - -import SecurityIcon from "@mui/icons-material/Security"; -import BugReportIcon from "@mui/icons-material/BugReport"; -import LocalPoliceIcon from "@mui/icons-material/LocalPolice"; -import { colors } from "@Hooks/useSettings"; -import { useFormatDate } from "@Hooks/useFormatDate"; -import { useRepos } from "@Hooks/useRepos"; -import { ExploreModule } from "@Components/ExploreModule"; -import { CustomTextField } from "@Components/TextField"; -import { useFirebase } from "@Hooks/useFirebase"; -import ProfileDetailsActivity from "./ProfileDetailsActivity"; -import ChangeEmailActivity from "./ChangeEmailActivity"; -import ExploreModuleFragment, { ExploreModuleProps } from "@Activitys/fragments/ExploreModuleFragment"; - -const badgeStyle: (color: (typeof colors)["blue" | "teal" | "red" | "orange"]) => SxProps = (color) => { - return { - px: 1, - py: 0.5, - borderRadius: 1, - display: "flex", - typography: "caption", - bgcolor: (theme) => (theme.palette.mode === "dark" ? color[900] : color[50]), - color: (theme) => (theme.palette.mode === "dark" ? "#fff" : color[700]), - }; -}; - -const ProfileActivty = () => { - const { strings } = useStrings(); - const { modules } = useRepos(); - const { context, extra } = useActivity(); - const { firebaseVoid } = useFirebase(); - - const [username, setUsername] = React.useState(""); - const [bio, setBio] = React.useState(""); - const [picurl, setPicurl] = React.useState(""); - const [options, setOptions] = React.useState({}); - - React.useEffect(() => { - firebaseVoid((auth, db) => { - const dbRef = ref(db, "users/" + extra.uid); - onValue(query(dbRef), (snapshot) => { - const snap = snapshot.val(); - setUsername(snap.username); - setBio(snap.bio); - setPicurl(snap.picurl); - console.log(snap.options); - setOptions(snap.options); - }); - }); - }, []); - - const renderToolbar = () => { - return ( - - - - - {username} - - ); - }; - - return ( - - - - - - - - - {username} - - - {options?.roles?.verified && ( - - - Verified - - )} - {options?.roles?.mod && ( - - - MMRL Moderator - - )} - {options?.roles?.admin && ( - - - MMRL Admin - - )} - {options?.roles?.bughunter && ( - - - Bug Hunter - - )} - - - - - - - {bio && ( - - - - Biography - - - {bio} - - - - )} - - - - - Participating - - - - - {/* @ts-ignore */} - - {modules - .filter((m) => m.prop_url?.mmrlAuthor?.includes(extra.uid)) - .map((module, i) => ( - - - - ))} - - - - - - ); -}; - -export default ProfileActivty; diff --git a/Website/src/activitys/account/ProfileDetailsActivity.tsx b/Website/src/activitys/account/ProfileDetailsActivity.tsx deleted file mode 100644 index 6cabe38c..00000000 --- a/Website/src/activitys/account/ProfileDetailsActivity.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import { Menu } from "@mui/icons-material"; -import { useActivity } from "@Hooks/useActivity"; -import { Toolbar } from "@Components/onsenui/Toolbar"; -import { os } from "@Native/Os"; -import { Page } from "@Components/onsenui/Page"; -import { useStrings } from "@Hooks/useStrings"; -import { Tabbar, TabbarRenderTab } from "@Components/onsenui/Tabbar"; -import Register from "./fragments/Register"; -import Login from "./fragments/Login"; -import Paper from "@mui/material/Paper"; -import { CustomTextField } from "@Components/TextField"; -import React from "react"; - -import { set, ref, update, onValue, get, query } from "firebase/database"; -import { useFirebase } from "@Hooks/useFirebase"; -import Button from "@mui/material/Button"; -import Card from "@mui/material/Card"; - -const ProfileDetailsActivity = () => { - const { strings } = useStrings(); - const { context, extra } = useActivity(); - const { auth, firebaseVoid } = useFirebase(); - - const [username, setUsername] = React.useState(extra.username); - const [picurl, setPicurl] = React.useState(extra.picurl); - const [bio, setBio] = React.useState(extra.bio); - const [options, setOptions] = React.useState(extra.options); - - const renderToolbar = () => { - return ( - - - - - Profile details - - ); - }; - - const handleSaveChanges = () => { - firebaseVoid((auth, db) => { - update(ref(db, `users/${auth.currentUser?.uid}`), { - username: username, - picurl: picurl, - }) - .then(() => { - // context.popPage() - os.toast("Your changes have been saved", Toast.LENGTH_SHORT); - }) - .catch((err) => { - os.toast(err, Toast.LENGTH_SHORT); - }); - }); - }; - - return ( - - - -
- { - setUsername(event.target.value); - }} - inputProps={{ - maxLength: 20, - }} - type="text" - value={username} - label="Username" - variant="outlined" - /> - { - setPicurl(event.target.value); - }} - type="text" - value={picurl} - label="Picture URL" - variant="outlined" - /> - -
- - -
-
-
- ); -}; - -export default ProfileDetailsActivity; diff --git a/Website/src/activitys/account/fragments/Login.tsx b/Website/src/activitys/account/fragments/Login.tsx deleted file mode 100644 index 17feda58..00000000 --- a/Website/src/activitys/account/fragments/Login.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { Page } from "@Components/onsenui/Page"; -import { useActivity } from "@Hooks/useActivity"; -import { useSettings } from "@Hooks/useSettings"; -import Avatar from "@mui/material/Avatar"; -import Button from "@mui/material/Button"; -import Checkbox from "@mui/material/Checkbox"; -import FormControlLabel from "@mui/material/FormControlLabel"; -import Grid from "@mui/material/Grid"; -import Paper from "@mui/material/Paper"; -import TextField from "@mui/material/TextField"; -import LockOutlined from "@mui/icons-material/LockOutlined"; -import { signInWithEmailAndPassword } from "firebase/auth"; -import React from "react"; -import { useTheme } from "@Hooks/useTheme"; -import { os } from "@Native/Os"; -import { useFirebase } from "@Hooks/useFirebase"; - -const Login = () => { - const { context } = useActivity(); - const { settings } = useSettings(); - const { firebaseVoid } = useFirebase(); - - const { scheme } = useTheme(); - - const paperStyle = { padding: 20, width: "80%", margin: "20px auto" }; - const avatarStyle = { backgroundColor: scheme[900] }; - const btnstyle = { margin: "8px 0" }; - - const [email, setEmail] = React.useState(""); - const [password, setPassword] = React.useState(""); - - return ( - - - - - - - -

Login

-
- { - setEmail(event.target.value); - }} - label="E-Mail" - placeholder="Enter email" - type="email" - variant="outlined" - fullWidth - value={email} - required - /> - { - setPassword(event.target.value); - }} - label="Password" - margin="dense" - placeholder="Enter password" - type="password" - variant="outlined" - fullWidth - value={password} - required - /> - } label="Remember me" /> - - {/* - - - Forgot password ? - - - */} -
-
-
- ); -}; - -export default Login; diff --git a/Website/src/activitys/account/fragments/Register.tsx b/Website/src/activitys/account/fragments/Register.tsx deleted file mode 100644 index db022791..00000000 --- a/Website/src/activitys/account/fragments/Register.tsx +++ /dev/null @@ -1,120 +0,0 @@ -import { Page } from "@Components/onsenui/Page"; -import { useActivity } from "@Hooks/useActivity"; -import { useSettings } from "@Hooks/useSettings"; -import Avatar from "@mui/material/Avatar"; -import Button from "@mui/material/Button"; -import Checkbox from "@mui/material/Checkbox"; -import FormControlLabel from "@mui/material/FormControlLabel"; -import Grid from "@mui/material/Grid"; -import Paper from "@mui/material/Paper"; -import TextField from "@mui/material/TextField"; -import LockOutlined from "@mui/icons-material/LockOutlined"; -import React from "react"; -import { useTheme } from "@Hooks/useTheme"; -import { os } from "@Native/Os"; -import { useFirebase } from "@Hooks/useFirebase"; -import { createUserWithEmailAndPassword } from "firebase/auth"; -import { ref, set } from "firebase/database"; - -const Register = () => { - const { context } = useActivity(); - const { settings } = useSettings(); - const { firebaseVoid } = useFirebase(); - - const { scheme } = useTheme(); - - const paperStyle = { padding: 20, width: "80%", margin: "20px auto" }; - const avatarStyle = { backgroundColor: scheme[900] }; - const btnstyle = { margin: "8px 0" }; - - const [email, setEmail] = React.useState(""); - const [password, setPassword] = React.useState(""); - - // const mmru_id = React.useMemo(() => { - // // always start with a letter (for DOM friendlyness) - // let idstr = String.fromCharCode(Math.floor(Math.random() * 25 + 65)); - // do { - // // between numbers and characters (48 is 0 and 90 is Z (42-48 = 90) - // let ascicode = Math.floor(Math.random() * 42 + 48); - // if (ascicode < 58 || ascicode > 64) { - // // exclude all chars between : (58) and @ (64) - // idstr += String.fromCharCode(ascicode); - // } - // } while (idstr.length < 32); - - // return "MMRU_" + idstr; - // }, []); - - return ( - - - - - - - -

Register

-
- { - setEmail(event.target.value); - }} - label="E-Mail" - placeholder="Enter email" - type="email" - variant="outlined" - fullWidth - value={email} - required - /> - { - setPassword(event.target.value); - }} - label="Password" - margin="dense" - placeholder="Enter password" - type="password" - variant="outlined" - fullWidth - value={password} - required - /> - } label="Remember me" /> - - {/* - - - Forgot password ? - - - */} -
-
-
- ); -}; - -export default Register; diff --git a/Website/src/activitys/fragments/DrawerFragment.tsx b/Website/src/activitys/fragments/DrawerFragment.tsx index 4091871c..82061f15 100644 --- a/Website/src/activitys/fragments/DrawerFragment.tsx +++ b/Website/src/activitys/fragments/DrawerFragment.tsx @@ -2,13 +2,10 @@ import { DAPITestActivity } from "@Activitys/DAPITestActivity"; import DescriptonActivity from "@Activitys/DescriptonActivity"; import RepoActivity from "@Activitys/RepoActivity"; import SettingsActivity from "@Activitys/SettingsActivity"; -import NoAccountActivty from "@Activitys/account/NoAccountActivity"; import { StyledListItemText } from "@Components/StyledListItemText"; import { useStrings } from "@Hooks/useStrings"; import { Divider, List, ListItemButton, ListSubheader } from "@mui/material"; import { Page } from "react-onsenui"; -import AccountActivty from "@Activitys/account/AccountActivity"; -import { useFirebase } from "@Hooks/useFirebase"; import { IntentPusher } from "@Hooks/useActivity"; type Props = { @@ -20,34 +17,12 @@ type Props = { export const DrawerFragment = (props: Props) => { const hide = props.hideSplitter; const pushPage = props.pushPage; - const { auth } = useFirebase(); const { strings } = useStrings(); return ( ({ bgcolor: theme.palette.background.default })}>App}> - { - if (auth?.currentUser) { - pushPage({ - component: AccountActivty, - key: "acc", - props: {}, - extra: {}, - }); - } else { - pushPage({ - component: NoAccountActivty, - key: "no_acc", - }); - } - hide(); - }} - > - - - { pushPage({ diff --git a/Website/src/components/ExploreModule.tsx b/Website/src/components/ExploreModule.tsx index 3de088fb..155653e8 100644 --- a/Website/src/components/ExploreModule.tsx +++ b/Website/src/components/ExploreModule.tsx @@ -16,7 +16,6 @@ import { useModuleOptions } from "@Hooks/useModuleOptions"; import { GestureDetector } from "./onsenui/GestureDetector"; import { ref, onValue, query } from "firebase/database"; import React from "react"; -import { useFirebase } from "@Hooks/useFirebase"; import { useTheme } from "@Hooks/useTheme"; import useShadeColor from "@Hooks/useShadeColor"; import ModuleViewActivity from "@Activitys/ModuleViewActivity"; @@ -33,7 +32,6 @@ export const ExploreModule = (props: Props) => { const { settings } = useSettings(); const { theme, scheme } = useTheme(); const shade = useShadeColor(); - const { auth, firebaseVoid } = useFirebase(); const { id, notes_url, zip_url, last_update, prop_url } = props.moduleProps; @@ -45,21 +43,6 @@ export const ExploreModule = (props: Props) => { return null; } - const [authorData, setAuthorData] = React.useState({}); - - React.useEffect(() => { - if (prop_url?.mmrlAuthor) { - firebaseVoid((auth, db) => { - const dbRef = ref(db, "users/" + prop_url.mmrlAuthor); - onValue(query(dbRef), (snapshot) => { - setAuthorData(snapshot.val()); - }); - }); - } else { - setAuthorData(undefined); - } - }, []); - const handleOpen = () => { // context.pushPage({ // component: DescriptonActivity, @@ -81,7 +64,6 @@ export const ExploreModule = (props: Props) => { extra: { last_update: last_update, zip_url: zip_url, - authorData: authorData, notes_url: notes_url, module: prop_url, }, @@ -138,12 +120,7 @@ export const ExploreModule = (props: Props) => { {prop_url.version} ({prop_url.versionCode}) / - {prop_url.mmrlAuthor && authorData ? ( - {authorData.username ? authorData.username : prop_url.author} - ) : ( - {prop_url.author} - )} - {authorData?.options?.roles?.verified && } + {prop_url.author}
diff --git a/Website/src/hooks/useFirebase.tsx b/Website/src/hooks/useFirebase.tsx deleted file mode 100644 index a8aeab8a..00000000 --- a/Website/src/hooks/useFirebase.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import React from "react"; - -import { getDatabase, set, ref, update, onValue, Database } from "firebase/database"; -import { getAuth, createUserWithEmailAndPassword, Auth } from "firebase/auth"; -import { FirebaseApp, initializeApp } from "firebase/app"; -import { os } from "@Native/Os"; - -interface IFirebaseContext { - app: FirebaseApp | null; - auth: Auth | null; - database: Database | null; - firebaseVoid: (cb: (auth: Auth, db: Database) => void) => void; -} - -const FirebaseContext = React.createContext({ - app: null, - auth: null, - database: null, - firebaseVoid(cb) {}, -}); - -export const FirebaseProvider = (props: React.PropsWithChildren) => { - const [app, setApp] = React.useState(null); - const [auth, setAuth] = React.useState(null); - const [database, setDatabase] = React.useState(null); - - const config = React.useMemo( - () => ({ - apiKey: "AIzaSyB0z4WO8zpqu2Tf9tYJlYpc71pjSREBhaA", - databaseURL: "https://mmrl-80afa-default-rtdb.europe-west1.firebasedatabase.app/", - projectId: "mmrl-80afa", - storageBucket: "mmrl-80afa.appspot.com", - appId: "1:343713662395:android:e20d7b9250788d64f5b09e", - }), - [] - ); - - React.useEffect(() => { - setApp(initializeApp(config)); - }, []); - - React.useEffect(() => { - if (app) { - setAuth(getAuth(app)); - setDatabase(getDatabase(app)); - } - }, [app]); - - const firebaseVoid = (cb: (auth: Auth, db: Database) => void) => { - if (auth && database) { - cb(auth, database); - } - }; - - return ; -}; - -export const useFirebase = () => React.useContext(FirebaseContext); diff --git a/Website/src/index.tsx b/Website/src/index.tsx index 8e9755c5..5b32f8e6 100644 --- a/Website/src/index.tsx +++ b/Website/src/index.tsx @@ -14,7 +14,6 @@ import { MMRLApp } from "./custom-elements/app"; import "onsenui/css/onsenui.css"; import "@Styles/default.scss"; -import { FirebaseProvider } from "@Hooks/useFirebase"; ons.platform.select("android"); @@ -27,23 +26,21 @@ ons.ready(() => { render( - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + , "mmrl-app" );