Skip to content

Commit

Permalink
Merge pull request #44 from yrjarv/main
Browse files Browse the repository at this point in the history
First name instead of 'Profile' in right corner of header
  • Loading branch information
EricSvebakk authored Sep 26, 2024
2 parents 028e072 + 0b9a317 commit cee4b41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
19 changes: 14 additions & 5 deletions app/components/Login/LoginButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ export default function LoginButton(props) {
bgcolor: cybTheme.palette.primary.main,
};


const buttonText = () => {
if (session.data != undefined) {
let firstName = session.data.user.name.split(" ")[0].replace('-', '‑')
// Shorten the first name if it is longer than 15 characters
if (firstName.length > 15) {
firstName = firstName.slice(0, 12) + "..."
}
return firstName
}
return "Login"
}

return (
<>
Expand Down Expand Up @@ -84,7 +94,7 @@ export default function LoginButton(props) {
}}
primary={
<Typography variant="caption">
{session.data != undefined ? "Profile" : "Login"}
{buttonText()}
</Typography>
}
/>
Expand All @@ -105,11 +115,10 @@ export default function LoginButton(props) {
>
<Typography
variant="body1"
width="3em"
// color={cybTheme.palette.text.secondary}
sx={{ display: { xs: "none", md: "flex" } }}
>
{session.data != undefined ? "Profile" : "Login"}
{buttonText()}
</Typography>

{session.status == "authenticated" ? (
Expand All @@ -122,7 +131,7 @@ export default function LoginButton(props) {
) : (
<Avatar sx={{ ...avatarProps }}>
<Person
color={cybTheme.palette.background.main}
color={cybTheme.palette.background.main}
// color= sx={{
// color: cybTheme.palette.background.main
// }}
Expand Down
2 changes: 1 addition & 1 deletion app/components/layout/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class NavBar extends Component {
</Box>
</Grid>

<Grid item>
<Grid item sx={{ flexShrink: 1 }}>
<SessionProvider>
<LoginButton />
</SessionProvider>
Expand Down
9 changes: 4 additions & 5 deletions app/pages/main/profile/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ function ProfilePage() {
}
}, [session])

const handleUpdateData = () => {

prismaRequest({
const handleUpdateData = async () => {
await prismaRequest({
model: "user",
method: "update",
request: {
Expand All @@ -126,8 +125,8 @@ function ProfilePage() {
lastName: lastName,
}
}
})

});
window.location.reload();
}

const handleConfirmSelection = async () => {
Expand Down

0 comments on commit cee4b41

Please sign in to comment.