Add avatar to people page

This commit is contained in:
rotimi-best
2021-09-11 22:15:15 +03:00
parent 07eba6b4e0
commit 4a7843b0b4
3 changed files with 28 additions and 9 deletions
@@ -3,6 +3,7 @@ export interface Profile {
fullname: string;
username: string;
email: string;
avatar_url?: string;
}
export interface Person {
+17 -8
View File
@@ -14,6 +14,7 @@
import { onMount } from 'svelte';
import CourseContainer from '../../../components/CourseContainer/index.svelte';
import Delete24 from 'carbon-icons-svelte/lib/Delete24';
import Avatar from '../../../components/Avatar/index.svelte';
import PageNav from '../../../components/PageNav/index.svelte';
import PrimaryButton from '../../../components/PrimaryButton/index.svelte';
import TextField from '../../../components/Form/TextField.svelte';
@@ -165,14 +166,22 @@
{/if}
<!-- <span class="flex-grow" /> -->
{#if person.profile}
<div class="break-all w-2/4 mx-2">
<p class="text-lg">{person.profile.fullname}</p>
<a
href="mailto:{person.profile.email}"
class="text-md text-blue-600"
>
{person.profile.email}
</a>
<div class="w-2/4 mx-2 flex items-center">
<Avatar
src={person.profile.avatar_url}
name={person.profile.fullname}
/>
<div class="ml-2 break-all">
<p class="text-lg">{person.profile.fullname}</p>
{#if !isStudent}
<a
href="mailto:{person.profile.email}"
class="text-md text-blue-600"
>
{person.profile.email}
</a>
{/if}
</div>
</div>
{:else}
<div class="break-all w-2/4 mx-2">
+10 -1
View File
@@ -74,6 +74,7 @@
.getPublicUrl(filename);
updates.avatar_url = publicURL;
currentProfile.avatar_url = publicURL;
}
avatar = undefined;
}
@@ -104,8 +105,16 @@
}
}
$: isDirty =
avatar ||
initialValueOfUserName !== currentProfile.username ||
initialValueOfFullName !== currentProfile.fullname;
$: isOwner = $profile.id === profileId;
$: getProfile(profileId);
$: if (avatar) {
updateProfile();
}
</script>
<svelte:head>
@@ -149,7 +158,7 @@
isDisabled={true}
/>
{#if avatar || initialValueOfUserName !== currentProfile.username || initialValueOfFullName !== currentProfile.fullname}
{#if isDirty}
<PrimaryButton
label={loading ? 'Updating...' : 'Update profile'}
onClick={updateProfile}