Store last viewed org in local storage for better UX

This commit is contained in:
Rotimi Best
2023-09-13 20:22:15 +01:00
parent 56f979d76e
commit c07c119b5b
6 changed files with 33 additions and 16 deletions
@@ -5,15 +5,22 @@
import { currentOrg, orgs, currentOrgPath } from '$lib/utils/store/org';
import { goto } from '$app/navigation';
import { newOrgModal } from '$lib/components/Org/store';
import type { CurrentOrg } from '$lib/utils/types/org';
export let canAddOrg = true;
let open = false;
function handleAddOrg() {
console.log('add org modal');
open = false;
$newOrgModal.open = true;
}
function onClick(org: CurrentOrg) {
localStorage.setItem('classroomio_org_sitename', org.siteName);
currentOrg.set(org);
goto($currentOrgPath);
open = false;
}
</script>
<div class="mt-5 relative" data-outline>
@@ -45,11 +52,7 @@
avatarText={org.shortName}
text={org.name}
hasDivider={true}
onClick={() => {
currentOrg.set(org);
goto($currentOrgPath);
open = false;
}}
onClick={() => onClick(org)}
/>
{/each}