Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed language selector local storage #203

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions frontend/src/components/LanguageSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ const localeStorage = useLocalStorage('locale', locale.value);
*
* @param locale
*/
function updateLocale(locale: Ref<string>) {
function updateLocale(locale: string) {
// Update saved locale
localeStorage.value = locale.value;

localeStorage.value = locale;
// Update PrimeVue locale
config.locale = messages.value[locale.value]['primevue'] as PrimeVueLocaleOptions;
config.locale = messages.value[locale]['primevue'] as PrimeVueLocaleOptions;
}

/**
Expand All @@ -40,12 +39,12 @@ function getFlag(locale: string) {

/* Hooks */
onMounted(() => {
updateLocale(locale);
updateLocale(locale.value);
});
</script>

<template>
<Dropdown id="language" v-model="locale" class="w-auto" :options="availableLocales" @change="updateLocale" variant="outlined">
<Dropdown id="language" v-model="locale" class="w-auto" :options="availableLocales" @change="updateLocale($event.value)" variant="outlined">
<template #option="{ option }">
<div class="flex align-items-center">
<img :alt="t('layout.header.language.' + option)" :src="getFlag(option)" class="h-1rem mr-2"/>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/projects/GroupCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const props = defineProps<{
}>();

onMounted(async () => {
await getStudentsByGroup(props.groupId, t);
await getStudentsByGroup(props.groupId);
});

</script>
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/composables/services/admins.service.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import {Admin} from '@/types/Admin.ts';
import {ref} from 'vue';
import {endpoints} from '@/config/endpoints.ts';
import { get, getList, create, delete_id } from '@/composables/services/helpers.ts';
import {User} from '@/types/User.ts';

export function useAdmin() {
const admins = ref<Admin[]|null>(null);
const admin = ref<Admin|null>(null);
const admins = ref<User[]|null>(null);
const admin = ref<User|null>(null);

async function getAdminByID(id: string) {
const endpoint = endpoints.admins.retrieve.replace('{id}', id);
await get<Admin>(endpoint, admin, Admin.fromJSON);
await get<User>(endpoint, admin, User.fromJSON);
}

async function getAdmins() {
const endpoint = endpoints.admins.index;
await getList<Admin>(endpoint, admins, Admin.fromJSON);
await getList<User>(endpoint, admins, User.fromJSON);
}

async function createAdmin(admin_data: Admin) {
async function createAdmin(admin_data: User) {
const endpoint = endpoints.admins.index;
await create<Admin>(endpoint,
await create<User>(endpoint,
{
email:admin_data.email,
first_name:admin_data.first_name,
last_name: admin_data.last_name
},
admin, Admin.fromJSON);
admin, User.fromJSON);
}

async function deleteAdmin(id: string) {
const endpoint = endpoints.admins.retrieve.replace('{id}', id);
await delete_id<Admin>(endpoint, admin, Admin.fromJSON);
await delete_id<User>(endpoint, admin, User.fromJSON);
}

return {
Expand Down
1 change: 1 addition & 0 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"types": ["cypress"],

/* Bundler mode */
"moduleResolution": "bundler",
Expand Down
Loading