bugfix, profile picture WIP, profile frontend refactored

This commit is contained in:
2024-04-14 20:31:16 +02:00
parent c892ef5b6e
commit 29c72d13e7
25 changed files with 784 additions and 402 deletions

View File

@@ -18,7 +18,7 @@ export default class API {
return this.loggedIn ? this.session.csrfToken : null;
}
async apiCall(method, params, expectBinary=false) {
async apiCall(method, params = {}, expectBinary=false) {
params = params || { };
const csrfToken = this.csrfToken();
const config = {method: 'post'};

View File

@@ -0,0 +1,45 @@
import {Box, styled} from "@mui/material";
import {useContext} from "react";
import {LocaleContext} from "../locale";
const PictureBox = styled("img")({
width: "100%",
clipPath: "circle(50%)",
});
const PicturePlaceholderBox = styled(Box)((props) => ({
display: "flex",
justifyContent: "center",
alignItems: "center",
background: "radial-gradient(circle closest-side, gray 98%, transparent 100%);",
containerType: "inline-size",
"& > span": {
textAlign: "center",
fontSize: "30cqw",
color: "black",
}
}));
export default function ProfilePicture(props) {
const {user, ...other} = props;
const {translate: L} = useContext(LocaleContext);
const initials = (user.fullName || user.name)
.split(" ")
.map(n => n.charAt(0).toUpperCase())
.join("");
const isClickable = !!other.onClick;
const sx = isClickable ? {cursor: "pointer"} : {};
if (user.profilePicture) {
return <PictureBox src={`/img/uploads/user/${user.id}/${user.profilePicture}`} sx={sx}
alt={L("account.profile_picture_of") + " " + (user.fullName || user.name)}
{...other} />;
} else {
return <PicturePlaceholderBox sx={sx} {...other}>
<span>{initials}</span>
</PicturePlaceholderBox>;
}
}

View File

@@ -139,7 +139,6 @@ export default function LoginForm(props) {
type: "public-key",
}],
userVerification: "discouraged",
attestation: "direct",
},
signal: abortSignal
}).then((res) => {