feat: profile page, EXCEPT FUCKING AVATARS AAAAAHHH
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
This commit is contained in:
parent
256889a573
commit
622abc9155
7 changed files with 148 additions and 40 deletions
|
@ -3,8 +3,12 @@
|
||||||
<img v-if="props.user.avatar" id="avatar" :src="props.user.avatar" alt="profile avatar">
|
<img v-if="props.user.avatar" id="avatar" :src="props.user.avatar" alt="profile avatar">
|
||||||
<div id="cover-colour"></div>
|
<div id="cover-colour"></div>
|
||||||
<div id="main-body">
|
<div id="main-body">
|
||||||
<p id="display-name"><strong>{{ props.user.display_name || "display_name" }}</strong></p>
|
<p id="display-name">
|
||||||
<p id="username"> {{ props.user.username || "username" }}</p>
|
<strong>{{ props.user.display_name || "display_name" }}</strong>
|
||||||
|
</p>
|
||||||
|
<p id="username-and-pronouns">
|
||||||
|
{{ props.user.username || "username" }} - {{ props.user.pronouns || "un/defined" }}
|
||||||
|
</p>
|
||||||
<div id="about-me">
|
<div id="about-me">
|
||||||
<span>About me</span>
|
<span>About me</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,15 +22,15 @@ import type { UserResponse } from '~/types/interfaces';
|
||||||
const { fetchMembers } = useApi();
|
const { fetchMembers } = useApi();
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
user: UserResponse,
|
user: UserResponse | any, // actually UserResponse | null but TS is yelling at me again
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
#profile-popup {
|
#profile-popup {
|
||||||
min-width: 200px;
|
min-width: 300px;
|
||||||
max-width: 200px;
|
max-width: 300px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -34,46 +38,44 @@ const props = defineProps<{
|
||||||
}
|
}
|
||||||
|
|
||||||
#cover-colour {
|
#cover-colour {
|
||||||
border-radius: 8px 8px 0 0;
|
border-radius: 12px 12px 0 0;
|
||||||
min-height: 52px;
|
min-height: 60px;
|
||||||
background-color: #442505;
|
background-color: #442505;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-body {
|
#main-body {
|
||||||
border-radius: 0 0 8px 8px;
|
border-radius: 0 0 12px 12px;
|
||||||
padding: 8px;
|
padding: 12px;
|
||||||
min-height: 180px;
|
min-height: 280px;
|
||||||
background-color: #4b3018;
|
background-color: #4b3018;
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
hyphens: manual;
|
hyphens: manual;
|
||||||
}
|
}
|
||||||
|
|
||||||
#avatar {
|
#avatar {
|
||||||
width: 64px;
|
width: 96px;
|
||||||
border: 4px solid #4b3018;
|
height: 96px;
|
||||||
|
border: 5px solid #4b3018;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 12px;
|
left: 16px;
|
||||||
top: 12px;
|
top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#display-name {
|
#display-name {
|
||||||
margin-top: 28px;
|
margin-top: 60px;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-size: 18px;
|
font-size: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#username {
|
#username-and-pronouns {
|
||||||
margin-top: 2px;
|
margin: 2px;
|
||||||
margin-bottom: 0;
|
font-size: 16px;
|
||||||
font-size: 12px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#about-me {
|
#about-me {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
font-size: 14px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -28,11 +28,11 @@ const props = defineProps<{
|
||||||
background-color: #b35719;
|
background-color: #b35719;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|
||||||
padding: 8px 16px;
|
padding: 8px 18px;
|
||||||
font-size: 16px;
|
font-size: 18px;
|
||||||
transition: background-color 0.2s;
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
border-radius: 16px;
|
border-radius: 12px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ const props = defineProps<{
|
||||||
background-color: #f02f2f;
|
background-color: #f02f2f;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|
||||||
padding: 8px 16px;
|
padding: 8px 18px;
|
||||||
font-size: 16px;
|
font-size: 18px;
|
||||||
transition: background-color 0.2s;
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
border-radius: 16px;
|
border-radius: 12px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,31 @@
|
||||||
<div>
|
<div>
|
||||||
<h1>My Account</h1>
|
<h1>My Account</h1>
|
||||||
|
|
||||||
<div id="profile-container">
|
<div class="profile-and-user-data-fields">
|
||||||
<Userpopup :user=user_me></Userpopup>
|
<div class="user-data-fields">
|
||||||
|
<h3 class="subtitle">AVATAR</h3>
|
||||||
|
<Button text="Change Avatar" :callback="changeAvatar"></Button>
|
||||||
|
<Button text="Remove Avatar" :callback="removeAvatar" style="margin-left: 10px; background-color: grey;"></Button>
|
||||||
|
<h3 class="subtitle">DISPLAY NAME</h3>
|
||||||
|
<input type="text" v-model="user.display_name" placeholder="Enter display name" />
|
||||||
|
<h3 class="subtitle">USERNAME</h3>
|
||||||
|
<input type="text" v-model="user.username" placeholder="Enter username" />
|
||||||
|
<h3 class="subtitle">PRONOUNS</h3>
|
||||||
|
<input type="text" v-model="user.pronouns" placeholder="Enter pronouns" />
|
||||||
|
<h3 class="subtitle">ABOUT ME</h3>
|
||||||
|
<p>{{ user?.about_me || "TBD" }}</p>
|
||||||
|
|
||||||
|
<Button text="Save Changes" :callback="saveChanges"></Button>
|
||||||
|
</div>
|
||||||
|
<Userpopup :user=user_me class="profile"></Userpopup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- i love html -->
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
<h2>Password (and eventually authenticator)</h2>
|
<h2>Password (and eventually authenticator)</h2>
|
||||||
<Button text="Reset Password (tbd)" :callback=resetPassword></Button>
|
<Button text="Reset Password (tbd)" :callback=resetPassword></Button>
|
||||||
|
|
||||||
|
@ -19,10 +40,81 @@
|
||||||
import Button from '~/components/buttons/Button.vue';
|
import Button from '~/components/buttons/Button.vue';
|
||||||
import ButtonScary from '~/components/buttons/ButtonScary.vue';
|
import ButtonScary from '~/components/buttons/ButtonScary.vue';
|
||||||
|
|
||||||
const { user, fetchUser } = useAuth();
|
const { fetchUser } = useAuth();
|
||||||
|
|
||||||
const user_me = await fetchUser()
|
const user_me = await fetchUser()
|
||||||
|
let user_reference = Object.assign({}, user_me)
|
||||||
|
const user = user_me!
|
||||||
|
|
||||||
|
let new_pfp_file: any = null
|
||||||
|
|
||||||
|
const saveChanges = async () => {
|
||||||
|
try {
|
||||||
|
const formData = new FormData()
|
||||||
|
|
||||||
|
if (new_pfp_file) {
|
||||||
|
formData.append('avatar', new_pfp_file, new_pfp_file.name)
|
||||||
|
new_pfp_file = null
|
||||||
|
}
|
||||||
|
|
||||||
|
// oh lord praise deep seek v3
|
||||||
|
const jsonBlob = new Blob(
|
||||||
|
[JSON.stringify({
|
||||||
|
display_name: user.display_name,
|
||||||
|
username: user.username,
|
||||||
|
pronouns: user.pronouns,
|
||||||
|
})],
|
||||||
|
{ type: 'application/json' }
|
||||||
|
);
|
||||||
|
formData.append('json', jsonBlob, 'data.json');
|
||||||
|
|
||||||
|
await fetchWithApi("/me", {
|
||||||
|
method: "PATCH",
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
|
||||||
|
user_reference = Object.assign({}, user_me)
|
||||||
|
alert("success!!")
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error?.response?.status !== 200) {
|
||||||
|
const errorData = await error?.response?.json()
|
||||||
|
|
||||||
|
alert(`error ${error?.response?.status} met whilst trying to update profile info\n${errorData}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const removeAvatar = async () => {
|
||||||
|
alert("TBD")
|
||||||
|
// await fetchWithApi(`/auth/reset-password`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeAvatar = async () => {
|
||||||
|
try {
|
||||||
|
let input = document.createElement('input');
|
||||||
|
input.type = 'file';
|
||||||
|
input.accept = 'image/*';
|
||||||
|
|
||||||
|
input.onchange = async(e) => {
|
||||||
|
const file = e.target.files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
new_pfp_file = file;
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = (e) => {
|
||||||
|
user.avatar = e?.target?.result;
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.oncancel = () => alert("cancelled upload!");
|
||||||
|
input.click();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('User canceled or error:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const resetPassword = async () => {
|
const resetPassword = async () => {
|
||||||
alert("TBD")
|
alert("TBD")
|
||||||
|
@ -35,11 +127,24 @@ const deleteAccount = async () => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
#profile-container {
|
.profile-container {
|
||||||
border: 2px solid orange;
|
|
||||||
min-width: 250px;
|
min-width: 250px;
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profile-and-user-data-fields {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-container, .user-data-fields {
|
||||||
|
min-width: 350px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 800;
|
||||||
|
margin: 12px 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
|
@ -76,7 +76,6 @@ export const useAuth = () => {
|
||||||
if (!accessToken.value) return;
|
if (!accessToken.value) return;
|
||||||
console.log("fetchuser access token:", accessToken.value);
|
console.log("fetchuser access token:", accessToken.value);
|
||||||
const res = await fetchWithApi("/me") as UserResponse;
|
const res = await fetchWithApi("/me") as UserResponse;
|
||||||
res.avatar = res.avatar ?? "https://gorb.b-cdn.net/avatar/default-pfp.png";
|
|
||||||
user.value = res;
|
user.value = res;
|
||||||
return user.value;
|
return user.value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,8 @@ const selectCategory = (_category: Category, page: Page) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
#sidebar {
|
#sidebar {
|
||||||
min-width: 200px;
|
min-width: 250px;
|
||||||
max-width: 200px;
|
max-width: 250px;
|
||||||
background-color: #2f3136;
|
background-color: #2f3136;
|
||||||
color: white;
|
color: white;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
@ -127,7 +127,7 @@ const selectCategory = (_category: Category, page: Page) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
#sidebar h2 {
|
#sidebar h2 {
|
||||||
font-size: 1.5em;
|
font-size: 2em;
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,7 @@ const selectCategory = (_category: Category, page: Page) => {
|
||||||
#sidebar li {
|
#sidebar li {
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
|
font-size: 1.3em;
|
||||||
margin: 2px 0;
|
margin: 2px 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
|
@ -155,7 +156,7 @@ const selectCategory = (_category: Category, page: Page) => {
|
||||||
|
|
||||||
#sub_page {
|
#sub_page {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
max-width: 600px;
|
max-width: 800px;
|
||||||
margin-left: 1.5rem;
|
margin-left: 1.5rem;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,9 @@ export interface UserResponse {
|
||||||
uuid: string,
|
uuid: string,
|
||||||
username: string,
|
username: string,
|
||||||
display_name: string | null,
|
display_name: string | null,
|
||||||
avatar: string,
|
avatar: string | null,
|
||||||
pronouns: string | null,
|
pronouns: string | null,
|
||||||
|
about_me: string | null,
|
||||||
email?: string,
|
email?: string,
|
||||||
email_verified?: boolean
|
email_verified?: boolean
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue