Skip to content

Commit

Permalink
resolved conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ayandajuqu committed Sep 17, 2024
2 parents b5e0219 + d774917 commit 0679a44
Show file tree
Hide file tree
Showing 88 changed files with 3,923 additions and 1,702 deletions.
Binary file added bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "dependencies": { "@types/three": "^0.168.0" } }
5 changes: 5 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.svelte' {
import type { ComponentType } from 'svelte';
const component: ComponentType;
export default component;
}
3 changes: 2 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@threlte/extras": "^8.11.4",
"@threlte/xr": "^0.1.4",
"@types/canvas-confetti": "^1.6.4",
"@types/three": "^0.168.0",
"@vercel/analytics": "^1.3.1",
"@vercel/speed-insights": "^1.0.12",
"aws-sdk": "^2.1670.0",
Expand All @@ -86,6 +87,6 @@
"stream-chat": "^8.37.0",
"svelte-french-toast": "^1.2.0",
"svelte-tweakpane-ui": "^1.3.0",
"three": "^0.165.0"
"three": "^0.168.0"
}
}
91 changes: 79 additions & 12 deletions src/src/lib/components/common/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,92 @@
<!--
<script>
import { Avatar, Navbar, DarkMode } from 'flowbite-svelte';
import BreadCrumbs from '$lib/components/common/Breadcrumbs.svelte';
import { change } from '$lib/store';
import { getUserData } from '$lib/utils';
import { onMount } from 'svelte';
export let data;
$: ({ name, image, maps } = data);
let isMobile;
async function updateUserData() {
try {
const user = await getUserData();
name = user.name;
image = user.image;
} catch (error) {
console.error('There was a problem with the get operation:', error);
}
}
onMount(async () => {
updateUserData();
const checkMobile = () => {
isMobile = window.innerWidth < 768;
};
checkMobile();
window.addEventListener('resize', checkMobile);
return () => {
window.removeEventListener('resize', checkMobile);
};
});
$: {
change.subscribe(async () => {
await updateUserData();
});
}
</script>
<Navbar data-testid="navbar">
<BreadCrumbs {maps} />
<div class="m-4 {isMobile ? 'ml-4' : 'ml-72'}">
<Navbar
data-testid="navbar"
class="glassmorphic rounded-xl bg-white/60 px-4 py-2 shadow-md dark:bg-gray-900/60 transition-all duration-300 ease-in-out"
>
{#if !isMobile}
<BreadCrumbs {maps} />
{/if}
<div class="flex items-center md:order-2">
<DarkMode
class="mx-2 border text-gray-500 dark:border-gray-800 dark:text-gray-600"
data-testid="darkmode"
/>
<div class="flex items-center md:order-2">
<DarkMode
class="mx-2 border text-gray-500 dark:border-gray-800 dark:text-gray-600"
data-testid="darkmode"
/>
<Avatar id="avatar-menu" src={image} class="mx-2" data-testid="avatar" />
<Avatar id="avatar-menu" src={image} class="mx-2" data-testid="avatar" />
<div class="mx-2">
<div class="text-lg font-semibold">{name}</div>
{#if !isMobile}
<div class="mx-2">
<div class="text-lg font-semibold">{name}</div>
</div>
{/if}
</div>
</div>
</Navbar>
</Navbar>
</div>
<style>
.glassmorphic {
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
position: relative;
overflow: hidden;
}
.glassmorphic::before {
content: "";
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
transform: rotate(30deg);
pointer-events: none;
}
</style>
-->
58 changes: 58 additions & 0 deletions src/src/lib/components/common/Navbar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script lang="ts">
import { Navbar, NavBrand, NavLi, NavUl, NavHamburger } from 'flowbite-svelte';
export let role: 'lecturer' | 'admin' | 'student';
export let activeUrl = '';
const navLinks = {
admin: [
{ name: 'Dashboard', href: '/dashboard' },
{ name: 'Announcements', href: '/announcements' },
{ name: 'Organisation', href: '/organisation' },
{ name: 'Workspaces', href: '/workspaces' },
{ name: 'Admins', href: '/admins' },
{ name: 'Lecturers', href: '/lecturers' },
{ name: 'Students', href: '/students' }
],
lecturer: [
{ name: 'Workspaces', href: '/workspaces' },
{ name: 'Announcements', href: '/announcements' }
],
student: [
{ name: 'Dashboard', href: '/dashboard' },
{ name: 'Workspaces', href: '/workspaces' },
{ name: 'Announcements', href: '/announcements' },
{ name: 'Grades', href: '/grades' }
]
};
const commonLinks = [
{ name: 'Settings', href: '/settings' },
{ name: 'FAQ', href: '/faq' }
];
const currentLinks = navLinks[role];
</script>

<Navbar class="fixed start-0 top-0 z-20 w-full border-b px-2 py-2.5 sm:px-4">
<NavBrand href="/">
<img src="images/class-connect-logo.png" class="mr-3 h-8 sm:h-10" alt="ClassConnect Logo" />
<span
class="self-center whitespace-nowrap text-xl font-semibold text-gray-800 transition-colors duration-300 dark:text-white"
>ClassConnect</span
>
</NavBrand>
<NavHamburger />
<NavUl>
{#each currentLinks as { name, href }}
<NavLi {href} active={activeUrl === href}>
{name}
</NavLi>
{/each}
{#each commonLinks as { name, href }}
<NavLi {href} active={activeUrl === href}>
{name}
</NavLi>
{/each}
</NavUl>
</Navbar>
108 changes: 50 additions & 58 deletions src/src/lib/components/common/Profile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,29 @@
import { Button, Modal, Gallery } from 'flowbite-svelte';
import DeleteProfilePic from '$lib/components/modals/settings/DeleteProfilePic.svelte';
import UploadPicture from '$lib/components/modals/settings/UploadPicture.svelte';
import Settings from '$lib/components/common/ProfileSettings.svelte';
import UpdateGeneralDetails from '$lib/components/forms/UpdateGeneralDetails.svelte';
import UpdatePassword from '$lib/components/forms/UpdatePassword.svelte';
import { change } from '$lib/store';
import axios from 'axios';
import { getUserData } from '$lib/utils';
import { onMount } from 'svelte';
export let user: any;
let openEditProfile = false;
let openDeleteModal = false;
let openFileHandlingModal = false;
let update = false;
let loading = true;
export let loading: boolean;
const apiUrl = '/api/user';
async function getUserData() {
async function updateUserData() {
loading = true;
try {
axios
.get(apiUrl)
.then((response) => {
console.log('User data:', response.data);
user = response.data;
loading = false;
})
.catch((error) => {
if (error.response) {
console.error('Error response data:', error.response.data);
console.error('Error response status:', error.response.status);
} else if (error.request) {
console.error('Error request:', error.request);
} else {
console.error('Error message:', error.message);
}
loading = false;
});
user = await getUserData();
loading = false;
} catch (error) {
console.error('There was a problem with the get operation:', error);
console.error('There was a problem with the get operation');
loading = false;
} finally {
loading = false;
}
}
Expand All @@ -49,13 +35,15 @@
}
onMount(async () => {
await getUserData();
loading = false;
await updateUserData();
console.log('Updated loading state:', loading);
console.log('Updated user state:', user);
});
$: {
change.subscribe(() => {
getUserData();
change.subscribe(async () => {
await updateUserData();
});
}
</script>
Expand All @@ -71,32 +59,20 @@
/>
<!-- User Profile Image -->
<div class="mx-auto flex w-full justify-center">
{#if loading}
<svg
class="xs:w-[8rem] xs:h-[8rem] xs:bottom-[4.3rem] relative me-4 h-8 w-8 animate-pulse rounded-full object-cover text-gray-200 shadow-xl outline outline-2 outline-offset-2 outline-green-500 dark:text-gray-700 sm:bottom-[5rem] sm:h-[10rem] sm:w-[10rem] md:bottom-[6rem] md:h-[12rem] md:w-[12rem] lg:bottom-[8rem] lg:h-[16rem] lg:w-[16rem] xl:bottom-[7rem] xl:h-[16rem] xl:w-[16rem]"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 32 32"
><title>ProfileIcon</title><circle cx="16" cy="16" r="16" fill="#666" />
<path
d="M12.73 13.1a3.271 3.271 0 1 1 3.27 3.2 3.237 3.237 0 0 1-3.27-3.2zm-2.73 9.069h1.088a4.91 4.91 0 0 1 9.818 0h1.094a5.884 5.884 0 0 0-3.738-5.434 4.238 4.238 0 0 0 2.1-3.635 4.366 4.366 0 0 0-8.73 0 4.238 4.238 0 0 0 2.1 3.635 5.878 5.878 0 0 0-3.732 5.434z"
fill="#eee"
/>
<path fill="none" d="M0 0h32v32h-32z" />
</svg>
{:else}
<button
type="button"
on:click={() => (openEditProfile = true)}
on:keydown={handleKeyDown}
class="xs:w-[8rem] xs:h-[8rem] xs:bottom-[4.3rem] relative rounded-full object-cover shadow-xl outline outline-2 outline-offset-2 outline-green-500 sm:bottom-[5rem] sm:h-[10rem] sm:w-[10rem] md:bottom-[6rem] md:h-[12rem] md:w-[12rem] lg:bottom-[8rem] lg:h-[16rem] lg:w-[16rem] xl:bottom-[7rem] xl:h-[16rem] xl:w-[16rem]"
>
<img
src={user.image}
alt="User Profile"
class="h-full w-full rounded-full object-cover"
/>
</button>
{/if}
<button
type="button"
on:click={() => (openEditProfile = true)}
on:keydown={handleKeyDown}
data-testid="editProfileButtonProfile"
class="xs:w-[8rem] xs:h-[8rem] xs:bottom-[4.3rem] relative rounded-full object-cover shadow-xl outline outline-2 outline-offset-2 outline-green-500 sm:bottom-[5rem] sm:h-[10rem] sm:w-[10rem] md:bottom-[6rem] md:h-[12rem] md:w-[12rem] lg:bottom-[8rem] lg:h-[16rem] lg:w-[16rem] xl:bottom-[7rem] xl:h-[16rem] xl:w-[16rem]"
>
<img
src={user.image}
alt="User Profile"
class="h-full w-full animate-pulse rounded-full object-cover"
class:animate-pulse={loading}
/>
</button>
</div>

<div
Expand Down Expand Up @@ -136,20 +112,28 @@

<!-- Update Link -->
<div class="flex rounded-sm px-2">
<Button on:click={() => (update = !update)}>Update Details</Button>
<Button data-testid="updatedetailsbtn" on:click={() => (update = !update)}
>Update Details</Button
>
</div>
</div>
</div>
</section>
</div>

<!-- Edit Modal -->
<Modal id="deleteModal" bind:open={openEditProfile} size="md" placement="center">
<Modal
id="deleteModal"
data-testid="editModalProfile"
bind:open={openEditProfile}
size="md"
placement="center"
>
<form class="p-6 text-center">
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">Edit Profile Picture</h3>
<div class="flex justify-center">
<Gallery class="gap-4 py-2">
<img class="h-96 w-96 rounded-full" src={user.image} alt="Proffile" />
<img class="h-96 w-96 rounded-full" src={user.image} alt="Profile" />
</Gallery>
</div>
<div class="flex justify-center gap-4">
Expand Down Expand Up @@ -179,5 +163,13 @@

<!-- Update forms -->
{#if update}
<Settings {user} />
<div
data-testid="updateforms"
class="grid grid-cols-1 px-4 pt-6 dark:bg-gray-900 xl:grid-cols-3 xl:gap-4"
>
<div class="col-span-10 items-center">
<UpdateGeneralDetails name={user.name} email={user.email} surname={user.surname} />
<UpdatePassword />
</div>
</div>
{/if}
Loading

0 comments on commit 0679a44

Please sign in to comment.