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; fullname: string;
username: string; username: string;
email: string; email: string;
avatar_url?: string;
} }
export interface Person { export interface Person {
+17 -8
View File
@@ -14,6 +14,7 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import CourseContainer from '../../../components/CourseContainer/index.svelte'; import CourseContainer from '../../../components/CourseContainer/index.svelte';
import Delete24 from 'carbon-icons-svelte/lib/Delete24'; import Delete24 from 'carbon-icons-svelte/lib/Delete24';
import Avatar from '../../../components/Avatar/index.svelte';
import PageNav from '../../../components/PageNav/index.svelte'; import PageNav from '../../../components/PageNav/index.svelte';
import PrimaryButton from '../../../components/PrimaryButton/index.svelte'; import PrimaryButton from '../../../components/PrimaryButton/index.svelte';
import TextField from '../../../components/Form/TextField.svelte'; import TextField from '../../../components/Form/TextField.svelte';
@@ -165,14 +166,22 @@
{/if} {/if}
<!-- <span class="flex-grow" /> --> <!-- <span class="flex-grow" /> -->
{#if person.profile} {#if person.profile}
<div class="break-all w-2/4 mx-2"> <div class="w-2/4 mx-2 flex items-center">
<p class="text-lg">{person.profile.fullname}</p> <Avatar
<a src={person.profile.avatar_url}
href="mailto:{person.profile.email}" name={person.profile.fullname}
class="text-md text-blue-600" />
> <div class="ml-2 break-all">
{person.profile.email} <p class="text-lg">{person.profile.fullname}</p>
</a> {#if !isStudent}
<a
href="mailto:{person.profile.email}"
class="text-md text-blue-600"
>
{person.profile.email}
</a>
{/if}
</div>
</div> </div>
{:else} {:else}
<div class="break-all w-2/4 mx-2"> <div class="break-all w-2/4 mx-2">
+10 -1
View File
@@ -74,6 +74,7 @@
.getPublicUrl(filename); .getPublicUrl(filename);
updates.avatar_url = publicURL; updates.avatar_url = publicURL;
currentProfile.avatar_url = publicURL;
} }
avatar = undefined; avatar = undefined;
} }
@@ -104,8 +105,16 @@
} }
} }
$: isDirty =
avatar ||
initialValueOfUserName !== currentProfile.username ||
initialValueOfFullName !== currentProfile.fullname;
$: isOwner = $profile.id === profileId; $: isOwner = $profile.id === profileId;
$: getProfile(profileId); $: getProfile(profileId);
$: if (avatar) {
updateProfile();
}
</script> </script>
<svelte:head> <svelte:head>
@@ -149,7 +158,7 @@
isDisabled={true} isDisabled={true}
/> />
{#if avatar || initialValueOfUserName !== currentProfile.username || initialValueOfFullName !== currentProfile.fullname} {#if isDirty}
<PrimaryButton <PrimaryButton
label={loading ? 'Updating...' : 'Update profile'} label={loading ? 'Updating...' : 'Update profile'}
onClick={updateProfile} onClick={updateProfile}