Refactor avatar components across the application to use the new UserAvatar component, replacing instances of the Avatar component for improved consistency and maintainability.

This commit is contained in:
Rotimi Best
2026-03-28 23:22:55 +01:00
parent 935b1c493d
commit 2e38f7541b
18 changed files with 78 additions and 123 deletions
+11 -5
View File
@@ -288,9 +288,7 @@ export const profile = pgTable(
id: uuid().primaryKey().notNull(),
fullname: text().notNull(),
username: text().notNull(),
avatarUrl: text('avatar_url').default(
'https://tapaozmyjsuykgerrfkt.supabase.co/storage/v1/object/public/avatars/avatar.png'
),
avatarUrl: text('avatar_url'),
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' }).defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true, mode: 'string' }).defaultNow(),
email: varchar(),
@@ -591,6 +589,11 @@ export const course = pgTable(
isPublished: boolean('is_published').default(false),
isCertificateDownloadable: boolean('is_certificate_downloadable').default(false),
certificateTheme: text('certificate_theme'),
certificationDeadline: timestamp('certification_deadline', { withTimezone: true, mode: 'string' }),
certificationThreshold: integer('certification_threshold').default(100),
certificationRequiredExerciseId: uuid('certification_required_exercise_id'),
certificationExerciseMinScorePercent: integer('certification_exercise_min_score_percent'),
certificationEmailMessage: text('certification_email_message'),
status: text().default('ACTIVE').notNull(),
type: courseType().default('LIVE_CLASS')
},
@@ -904,7 +907,8 @@ export const exercise = pgTable(
.primaryKey()
.notNull(),
isUnlocked: boolean('is_unlocked').default(true),
dueBy: timestamp('due_by', { mode: 'string' })
dueBy: timestamp('due_by', { mode: 'string' }),
allowMultipleAttempts: boolean('allow_multiple_attempts').default(false).notNull()
},
(table) => [
foreignKey({
@@ -938,7 +942,9 @@ export const groupmember = pgTable(
profileId: uuid('profile_id'),
email: varchar(),
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' }).defaultNow(),
assignedStudentId: varchar('assigned_student_id')
assignedStudentId: varchar('assigned_student_id'),
certificateEarnedAt: timestamp('certificate_earned_at', { withTimezone: true, mode: 'string' }),
certificationEmailSentAt: timestamp('certification_email_sent_at', { withTimezone: true, mode: 'string' })
},
(table) => [
foreignKey({
-1
View File
@@ -29,7 +29,6 @@ export async function seedProfile({ usersData }: { usersData: TUserSeedData[] })
fullname: resolveFullName(user),
username: `${user.email.split('@')[0]}${Date.now()}`,
email: user.email,
avatarUrl: 'https://pgrest.classroomio.com/storage/v1/object/public/avatars/avatar.png',
canAddCourse: true,
isEmailVerified: true
}))
@@ -0,0 +1,4 @@
import UserAvatar from './user-avatar.svelte';
export { UserAvatar };
export { UserAvatar as default };
@@ -0,0 +1,22 @@
<script lang="ts">
import * as Avatar from '../../base/avatar';
import UserIcon from '@lucide/svelte/icons/user';
interface Props {
src?: string | null;
alt?: string;
class?: string;
iconClass?: string;
}
let { src, alt = 'User', class: className = 'size-6', iconClass = '' }: Props = $props();
</script>
<Avatar.Root class={className}>
{#if src}
<Avatar.Image {src} {alt} />
{/if}
<Avatar.Fallback>
<UserIcon class="ui:text-muted-foreground {iconClass || 'h-1/2 w-1/2'}" />
</Avatar.Fallback>
</Avatar.Root>