Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Fixes, user store & simplifications

Smaug6739d523704abd48
diff --git a/backend/classes/UsersManager.ts b/backend/classes/UsersManager.ts
index a324720e..64cff933 100644
--- a/backend/classes/UsersManager.ts
+++ b/backend/classes/UsersManager.ts
@@ -14,6 +14,19 @@ export class UsersManager extends Base<User> {
});
});
}
+ public getPublic(id: string): Promise<UserDB> {
+ return new Promise((resolve, reject) => {
+ this.app.db.query<UserDB[]>(
+ 'SELECT id, username, firstname, lastname, avatar, email, created_timestamp FROM users WHERE id = ? LIMIT 1',
+ [id],
+ async (err, results) => {
+ if (err) return reject('Internal database error.');
+ if (!results[0]) return reject('Bad id.');
+ resolve(results[0]);
+ },
+ );
+ });
+ }
public getById(id: string): Promise<UserDB> {
return new Promise((resolve, reject) => {
this.app.db.query<UserDB[]>('SELECT * FROM users WHERE id = ? LIMIT 1', [id], async (err, results) => {
diff --git a/backend/controllers/users.controller.ts b/backend/controllers/users.controller.ts
new file mode 100644
index 00000000..8b359cb1
--- /dev/null
+++ b/backend/controllers/users.controller.ts
@@ -0,0 +1,17 @@
+import BaseController from './BaseController';
+import { UsersManager } from '../classes';
+
+import type { User } from '../types';
+import type { Request, Response } from 'express';
+
+export default class Authentification extends BaseController<UsersManager, User> {
+ constructor(app: App) {
+ super(new UsersManager(app));
+ }
+ public async getMe(req: Request, res: Response) {
+ this.manager
+ .getPublic(req.user_id as string)
+ .then(r => res.status(200).json(this.utils.success(r)))
+ .catch(e => res.status(500).json(this.utils.error(e)));
+ }
+}
diff --git a/backend/routes/v1/users.ts b/backend/routes/v1/users.ts
new file mode 100644
index 00000000..88a12d18
--- /dev/null
+++ b/backend/routes/v1/users.ts
@@ -0,0 +1,21 @@
+import { Router } from 'express';
+import UsersCtrl from '../../controllers/users.controller';
+import authMid from '../../middlewares/auth';
+
+const UsersRouter: Router = Router();
+
+export default (client: App): Iroute => {
+ const controller = new UsersCtrl(client);
+ return {
+ route: 'users',
+ version: 1,
+ router() {
+ UsersRouter.get('/@me', authMid, (req, res) => controller.getMe(req, res));
+ //UsersRouter.get('/:id', authMid, (req, res) => controller.getDocument(req, res));
+ //UsersRouter.post('/', (req, res) => controller.add(req, res));
+ //UsersRouter.patch('/:id', authMid, (req, res) => controller.updateDocument(req, res));
+ //UsersRouter.delete('/:id', authMid, (req, res) => controller.deleteDocument(req, res));
+ return UsersRouter;
+ },
+ };
+};
diff --git a/frontend/App.vue b/frontend/App.vue
index 2967eee8..71424613 100644
--- a/frontend/App.vue
+++ b/frontend/App.vue
@@ -1,17 +1,9 @@
<template>
<div style="height: 100vh;">
<NuxtPage />
- <div id="backdrop"></div>
<Notification />
<ClientOnly>
<BackToTop />
</ClientOnly>
</div>
</template>
-
-<script setup lang="ts">
-import { useDocumentsStore, useCategoriesStore } from './store';
-
-useDocumentsStore().fetch();
-useCategoriesStore().fetch();
-</script>
\ No newline at end of file
diff --git a/frontend/components/DocumentCardFooter.vue b/frontend/components/DocumentCardFooter.vue
index 2e2a2c1e..3480ae85 100644
--- a/frontend/components/DocumentCardFooter.vue
+++ b/frontend/components/DocumentCardFooter.vue
@@ -23,7 +23,7 @@
</template>
<script lang="ts" setup>
-import type { Document } from '@/store';
+import type { Document } from '@/stores';
defineProps<{ document: Document; next?: Document; previous?: Document }>();
</script>
diff --git a/frontend/components/DocumentCardHeader.vue b/frontend/components/DocumentCardHeader.vue
index d0d33580..0dd6b4f4 100644
--- a/frontend/components/DocumentCardHeader.vue
+++ b/frontend/components/DocumentCardHeader.vue
@@ -104,7 +104,7 @@
</template>
<script setup lang="ts">
-import { type Document, useCategoriesStore } from '~/store';
+import { type Document, useCategoriesStore } from '~/stores';
const categories_store = useCategoriesStore();
const props = defineProps<{ doc: Document }>();
const category = computed(() => categories_store.getById(props.doc?.category || ''));
diff --git a/frontend/components/DocumentCardHeaderActionRow.vue b/frontend/components/DocumentCardHeaderActionRow.vue
index 6eb4ec79..ff38eb18 100644
--- a/frontend/components/DocumentCardHeaderActionRow.vue
+++ b/frontend/components/DocumentCardHeaderActionRow.vue
@@ -34,7 +34,7 @@
</template>
<script setup lang="ts">
-import { useDocumentsStore } from '~/store';
+import { useDocumentsStore } from '~/stores';
const router = useRouter();
const documentsStore = useDocumentsStore();
diff --git a/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue
index f450e5a8..f56e433d 100644
--- a/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue
+++ b/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue
@@ -20,7 +20,7 @@ import { Editor } from './Editor';
import Toolbar from './LazyToolbar.vue';
import compile from '~/helpers/markdown';
import InlineToolbar from '~/components/MarkdownEditor/InlineToolbar.vue';
-import type { Document } from '~/store';
+import type { Document } from '~/stores';
const props = defineProps<{ doc?: Document }>();
const document = ref<Document | Partial<Document>>({ ...props.doc });
diff --git a/frontend/components/MarkdownEditor/LazyToolbar.vue b/frontend/components/MarkdownEditor/LazyToolbar.vue
index a0ca6d6f..a4e98a32 100644
--- a/frontend/components/MarkdownEditor/LazyToolbar.vue
+++ b/frontend/components/MarkdownEditor/LazyToolbar.vue
@@ -19,7 +19,7 @@
</template>
<script setup lang="ts">
-import { useCategoriesStore, type Document } from "~/store";
+import { useCategoriesStore, type Document } from "~/stores";
const categoriesStore = useCategoriesStore();
const props = defineProps<{ document: Partial<Document> }>();
diff --git a/frontend/components/Modal.vue b/frontend/components/Modal.vue
index 6183111c..a29b383f 100644
--- a/frontend/components/Modal.vue
+++ b/frontend/components/Modal.vue
@@ -29,19 +29,6 @@ const emit = defineEmits(['close', 'confirm'])
</template>
<style lang="scss" scoped>
-.modal-mask {
- position: fixed;
- z-index: 100;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- transition: opacity 0.3s ease;
- font-size: initial;
-}
-
.modal-container {
width: 500px;
margin: auto;
@@ -50,9 +37,9 @@ const emit = defineEmits(['close', 'confirm'])
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
transition: all 0.3s ease;
+ font-size: initial;
}
-
.modal-body {
margin: 20px 0;
}
@@ -66,10 +53,7 @@ const emit = defineEmits(['close', 'confirm'])
}
-.modal-enter-from {
- opacity: 0;
-}
-
+.modal-enter-from,
.modal-leave-to {
opacity: 0;
}
diff --git a/frontend/components/Notification.vue b/frontend/components/Notification.vue
index 1ca79d42..85016bbe 100644
--- a/frontend/components/Notification.vue
+++ b/frontend/components/Notification.vue
@@ -16,7 +16,7 @@
</template>
<script setup lang="ts">
-import { useNotifications } from '~/store';
+import { useNotifications } from '~/stores';
const notifications = computed(() => useNotifications().getAll.reverse());
const close = (id: number) => useNotifications().remove(id);
diff --git a/frontend/components/sidebar/CollapseItem.vue b/frontend/components/sidebar/CollapseItem.vue
index 571d2f77..26fb3f5c 100644
--- a/frontend/components/sidebar/CollapseItem.vue
+++ b/frontend/components/sidebar/CollapseItem.vue
@@ -24,7 +24,6 @@
</template>
<script setup lang="ts">
import { type Item } from './tree_builder';
-import div from './Collapse.vue';
import SidebarItem from './SidebarItem.vue';
defineProps<{ item: Item, root?: boolean }>();
diff --git a/frontend/components/sidebar/Search.vue b/frontend/components/sidebar/Search.vue
index 8bd91a68..c8f6c396 100644
--- a/frontend/components/sidebar/Search.vue
+++ b/frontend/components/sidebar/Search.vue
@@ -36,7 +36,7 @@
</template>
<script setup lang="ts">
-import { useDocumentsStore } from '~/store';
+import { useDocumentsStore } from '~/stores';
const documents = computed(() => useDocumentsStore().getAll.filter(c => c.name.toLowerCase().includes(filter.value.toLowerCase())));
const filter = ref<string>('');
@@ -83,19 +83,6 @@ const handleSearchShortCut = (e: KeyboardEvent) => {
</script>
<style lang="scss" scoped>
-.modal-mask {
- position: fixed;
- z-index: 100;
- top: 0;
- left: 0;
- width: 100vw;
- height: 100vh;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- transition: opacity 0.3s ease;
- font-size: initial;
-}
-
.modal-container {
width: 600px;
margin: auto;
diff --git a/frontend/components/sidebar/Sidebar.vue b/frontend/components/sidebar/Sidebar.vue
index 78c5aae9..27b2f24b 100644
--- a/frontend/components/sidebar/Sidebar.vue
+++ b/frontend/components/sidebar/Sidebar.vue
@@ -1,4 +1,5 @@
<template>
+ <div :class="{ 'modal-mask': isMobile() && isOpened }"></div>
<Resizable>
<div class="sidebar-content">
<section class="header">
@@ -21,7 +22,7 @@ import Resizable from './Resizable.vue';
import IconClose from './IconClose.vue';
import IconApp from './IconApp.vue';
import Search from './Search.vue';
-import { useCategoriesStore, useDocumentsStore, type Category } from '~/store';
+import { useCategoriesStore, useDocumentsStore, type Category } from '~/stores';
import { ItemsManager, type Item } from './tree_builder';
import { navigationItems } from "./helpers";
@@ -75,16 +76,6 @@ onBeforeUnmount(() => {
window.removeEventListener('click', handleClickOutside);
document.removeEventListener('keypress', handleSearchShortCut)
});
-
-// Watch isOpened
-if (isMobile()) {
- watch(isOpened, (val) => {
- if (val) document.getElementById('backdrop')?.classList.add('backdrop');
- else document.getElementById('backdrop')?.classList.remove('backdrop');
- });
-}
-
-
</script>
<style scoped lang="scss">
diff --git a/frontend/components/sidebar/SidebarItem.vue b/frontend/components/sidebar/SidebarItem.vue
index 8ad516ee..b72d8312 100644
--- a/frontend/components/sidebar/SidebarItem.vue
+++ b/frontend/components/sidebar/SidebarItem.vue
@@ -10,7 +10,7 @@
<script setup lang="ts">
-import { useDocumentsStore, useCategoriesStore } from '~/store';
+import { useDocumentsStore, useCategoriesStore } from '~/stores';
const documentStore = useDocumentsStore();
const categoriesStore = useCategoriesStore();
@@ -19,7 +19,6 @@ import type { Item } from './tree_builder';
import { icons, navigationItems } from './helpers';
const { isOpened } = useSidebar();
const props = defineProps<{ item: Item }>();
-const isMobile = () => process.client ? window.innerWidth <= 768 : false;
function getIcon(item: Item) {
if ('icon' in item.data && item.data.icon) return item.data.icon;
diff --git a/frontend/components/sidebar/tree_builder.ts b/frontend/components/sidebar/tree_builder.ts
index a23c6218..d86dc26a 100644
--- a/frontend/components/sidebar/tree_builder.ts
+++ b/frontend/components/sidebar/tree_builder.ts
@@ -1,4 +1,4 @@
-import type { Document, Category } from '~/store';
+import type { Document, Category } from '~/stores';
import type { DefaultItem } from './helpers';
export interface Item {
diff --git a/frontend/composables/utils.ts b/frontend/composables/utils.ts
index 841af0fa..0557010b 100644
--- a/frontend/composables/utils.ts
+++ b/frontend/composables/utils.ts
@@ -23,12 +23,10 @@ export interface FetchOptions {
export const isMobile = () => (import.meta.client ? window.innerWidth <= 768 : false);
export const baseUrl = import.meta.env.VITE_BASE_API?.toString() || '';
-import type { DB_Document, DB_Category, DB_Ressource } from '../store/db_strustures';
+import type { DB_Document, DB_Category, DB_Ressource, User } from '../stores/db_strustures';
-export async function makeRequest(route: string, method: string, body: Object, retry = false): Promise<APIResult<DB_Document | DB_Category | DB_Ressource | DB_Document[] | DB_Category[] | DB_Ressource[]>> {
+export async function makeRequest(route: string, method: string, body: Object, retry = false): Promise<APIResult<DB_Document | DB_Category | DB_Ressource | DB_Document[] | DB_Category[] | DB_Ressource[] | User>> {
console.log(`[API] Requesting ${method} ${route}`);
- console.log(body);
-
const response = await fetch(`${baseUrl}/api/v1/${route}`, {
method: method,
body: method === 'GET' || method === 'DELETE' ? null : body instanceof FormData ? body : JSON.stringify(body),
diff --git a/frontend/pages/dashboard.vue b/frontend/pages/dashboard.vue
index edfba336..d87883cc 100644
--- a/frontend/pages/dashboard.vue
+++ b/frontend/pages/dashboard.vue
@@ -9,5 +9,11 @@
</template>
<script setup lang="ts">
import Sidebar from '~/components/sidebar/Sidebar.vue';
+import { useDocumentsStore, useCategoriesStore } from '@/stores';
+
definePageMeta({ breadcrumb: 'Home' });
+useDocumentsStore().fetch();
+useCategoriesStore().fetch();
+
+useUserStore().fetch().then(r => console.log(r))
</script>
\ No newline at end of file
diff --git a/frontend/pages/dashboard/backup.vue b/frontend/pages/dashboard/backup.vue
index 2de32714..d8460a18 100644
--- a/frontend/pages/dashboard/backup.vue
+++ b/frontend/pages/dashboard/backup.vue
@@ -14,7 +14,7 @@
</template>
<script setup lang="ts">
-import { useNotifications } from '~/store';
+import { useNotifications } from '~/stores';
const downloadLink = ref<string | null>(null);
const copyLink = () => navigator.clipboard.writeText(downloadLink.value!);
diff --git a/frontend/pages/dashboard/categories/[id].vue b/frontend/pages/dashboard/categories/[id].vue
index 62830cd3..eb70eb98 100644
--- a/frontend/pages/dashboard/categories/[id].vue
+++ b/frontend/pages/dashboard/categories/[id].vue
@@ -30,7 +30,7 @@
</template>
<script setup lang="ts">
-import { useCategoriesStore, useDocumentsStore } from '~/store';
+import { useCategoriesStore, useDocumentsStore } from '~/stores';
const route = useRoute();
const categoriesStore = useCategoriesStore();
const documentsStore = useDocumentsStore();
diff --git a/frontend/pages/dashboard/categories/edit.vue b/frontend/pages/dashboard/categories/edit.vue
index 582aadd8..122e4a9b 100644
--- a/frontend/pages/dashboard/categories/edit.vue
+++ b/frontend/pages/dashboard/categories/edit.vue
@@ -39,7 +39,7 @@
</template>
<script lang="ts" setup>
-import { useCategoriesStore, useNotifications } from '~/store';
+import { useCategoriesStore, useNotifications } from '~/stores';
const route = useRoute();
const categoriesStore = useCategoriesStore();
diff --git a/frontend/pages/dashboard/categories/index.vue b/frontend/pages/dashboard/categories/index.vue
index 3a79bb9a..e8e1c9e2 100644
--- a/frontend/pages/dashboard/categories/index.vue
+++ b/frontend/pages/dashboard/categories/index.vue
@@ -87,6 +87,6 @@
}
</style>
<script lang="ts" setup>
-import { useCategoriesStore } from '~/store'; // Adjust the path accordingly
+import { useCategoriesStore } from '~/stores'; // Adjust the path accordingly
const categoriesStore = useCategoriesStore();
</script>
\ No newline at end of file
diff --git a/frontend/pages/dashboard/categories/new.vue b/frontend/pages/dashboard/categories/new.vue
index 1d2649d9..e4c65bf7 100644
--- a/frontend/pages/dashboard/categories/new.vue
+++ b/frontend/pages/dashboard/categories/new.vue
@@ -31,7 +31,7 @@
</template>
<script lang="ts" setup>
-import { type Category, useCategoriesStore, useNotifications } from '~/store';
+import { type Category, useCategoriesStore, useNotifications } from '~/stores';
const categoriesStore = useCategoriesStore();
const category = ref<Category>({ id: '', name: '', icon: '', parent_id: '', order: 0, type: 'category' });
diff --git a/frontend/pages/dashboard/cdn.vue b/frontend/pages/dashboard/cdn.vue
index 6e08105e..9e4a5daa 100644
--- a/frontend/pages/dashboard/cdn.vue
+++ b/frontend/pages/dashboard/cdn.vue
@@ -27,7 +27,7 @@
</div>
</template>
<script setup lang="ts">
-import { useNotifications, useRessourcesStore, type DB_Ressource } from '~/store';
+import { useNotifications, useRessourcesStore, type DB_Ressource } from '~/stores';
const ressourcesStore = useRessourcesStore();
await ressourcesStore.fetch();
diff --git a/frontend/pages/dashboard/docs/[id].vue b/frontend/pages/dashboard/docs/[id].vue
index 6649961e..684ec72f 100644
--- a/frontend/pages/dashboard/docs/[id].vue
+++ b/frontend/pages/dashboard/docs/[id].vue
@@ -17,7 +17,7 @@
<script setup lang="ts">
-import { useDocumentsStore, type Document } from '@/store';
+import { useDocumentsStore, type Document } from '@/stores';
import TableOfContent from "@/components/table-of-content/TableOfContents.vue";
const route = useRoute();
diff --git a/frontend/pages/dashboard/docs/edit/[id].vue b/frontend/pages/dashboard/docs/edit/[id].vue
index 1bc8ead7..ab7d54f9 100644
--- a/frontend/pages/dashboard/docs/edit/[id].vue
+++ b/frontend/pages/dashboard/docs/edit/[id].vue
@@ -2,7 +2,7 @@
<MarkdownEditor v-if="document" ref="editor" :doc="document" @save="(data) => save(data)" />
</template>
<script lang="ts" setup>
-import { useNotifications, useDocumentsStore, type Document } from '@/store';
+import { useNotifications, useDocumentsStore, type Document } from '@/stores';
import MarkdownEditor from '~/components/MarkdownEditor/LazyMarkdownEditor.vue';
const store = useDocumentsStore();
diff --git a/frontend/pages/dashboard/docs/index.vue b/frontend/pages/dashboard/docs/index.vue
index 584d35b0..0c9d7f87 100644
--- a/frontend/pages/dashboard/docs/index.vue
+++ b/frontend/pages/dashboard/docs/index.vue
@@ -4,7 +4,7 @@
</template>
<script setup lang="ts">
-import { useDocumentsStore, useCategoriesStore } from '~/store';
+import { useDocumentsStore, useCategoriesStore } from '~/stores';
const documents = computed(() => useDocumentsStore().getAll)
const categoriesStore = useCategoriesStore();
diff --git a/frontend/pages/dashboard/docs/new.vue b/frontend/pages/dashboard/docs/new.vue
index 019f45d1..71dd24e4 100644
--- a/frontend/pages/dashboard/docs/new.vue
+++ b/frontend/pages/dashboard/docs/new.vue
@@ -2,7 +2,7 @@
<MarkdownEditor ref="editor" :doc="document" @save="(data) => save(data)" />
</template>
<script lang="ts" setup>
-import { useNotifications, useDocumentsStore, type Document } from '@/store';
+import { useNotifications, useDocumentsStore, type Document } from '@/stores';
import MarkdownEditor from '~/components/MarkdownEditor/LazyMarkdownEditor.vue';
const store = useDocumentsStore();
diff --git a/frontend/store/utils.ts b/frontend/store/utils.ts
deleted file mode 100644
index 2c65d18e..00000000
--- a/frontend/store/utils.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export interface APIResult<Data> {
- status: 'success' | 'error';
- message?: string;
- result?: Data;
-}
-
-export interface FetchOptions {
- id: string; // id of the ressource
-}
-
-export const baseUrl = import.meta.env.VITE_BASE_API?.toString() || '';
diff --git a/frontend/store/categories.store.ts b/frontend/stores/categories.store.ts
similarity index 97%
rename from frontend/store/categories.store.ts
rename to frontend/stores/categories.store.ts
index 008b2a14..f66c77ba 100644
--- a/frontend/store/categories.store.ts
+++ b/frontend/stores/categories.store.ts
@@ -13,7 +13,7 @@ export const useCategoriesStore = defineStore('categories', {
getChilds: state => (id: string) => state.categories.filter(c => c.parent_id == id),
},
actions: {
- fetch: async function (opts?: FetchOptions) {
+ fetch: function (opts?: FetchOptions) {
return new Promise(async (resolve, reject) => {
const request = await makeRequest(`categories/${opts?.id || ''}`, 'GET', {});
if (request.status == 'success') {
diff --git a/frontend/store/db_strustures.d.ts b/frontend/stores/db_strustures.d.ts
similarity index 93%
rename from frontend/store/db_strustures.d.ts
rename to frontend/stores/db_strustures.d.ts
index 0ddc53c5..afe53713 100644
--- a/frontend/store/db_strustures.d.ts
+++ b/frontend/stores/db_strustures.d.ts
@@ -34,7 +34,6 @@ export interface User {
lastname?: string;
avatar?: string;
email: string;
- password: string;
created_timestamp: string;
}
export interface DB_Ressource {
diff --git a/frontend/store/documents.store.ts b/frontend/stores/documents.store.ts
similarity index 96%
rename from frontend/store/documents.store.ts
rename to frontend/stores/documents.store.ts
index 6056dc48..6f63c4e3 100644
--- a/frontend/store/documents.store.ts
+++ b/frontend/stores/documents.store.ts
@@ -40,7 +40,7 @@ export const useDocumentsStore = defineStore('documents', {
},
},
actions: {
- fetch: async function <T extends FetchOptions>(opts?: T): Promise<'id' extends keyof T ? Document : Document[]> {
+ fetch: function <T extends FetchOptions>(opts?: T): Promise<'id' extends keyof T ? Document : Document[]> {
console.log(`[store/documents] Fetching documents with options: ${JSON.stringify(opts)}`);
return new Promise(async (resolve, reject) => {
const request = await makeRequest(`documents/${opts?.id || ''}?all=true`, 'GET', {});
diff --git a/frontend/store/index.ts b/frontend/stores/index.ts
similarity index 85%
rename from frontend/store/index.ts
rename to frontend/stores/index.ts
index f297a1d8..d3645028 100644
--- a/frontend/store/index.ts
+++ b/frontend/stores/index.ts
@@ -2,5 +2,4 @@ export * from './documents.store';
export * from './categories.store';
export * from './notifications.store';
export * from './ressources.store';
-export type * from './utils';
export type * from './db_strustures';
diff --git a/frontend/store/notifications.store.ts b/frontend/stores/notifications.store.ts
similarity index 100%
rename from frontend/store/notifications.store.ts
rename to frontend/stores/notifications.store.ts
diff --git a/frontend/store/ressources.store.ts b/frontend/stores/ressources.store.ts
similarity index 97%
rename from frontend/store/ressources.store.ts
rename to frontend/stores/ressources.store.ts
index 0414ceca..915a05da 100644
--- a/frontend/store/ressources.store.ts
+++ b/frontend/stores/ressources.store.ts
@@ -8,7 +8,7 @@ export const useRessourcesStore = defineStore('ressources', {
getAll: state => state.ressources,
},
actions: {
- fetch: async function () {
+ fetch: function () {
if (this.ressources.length > 0) return this.ressources;
return new Promise(async (resolve, reject) => {
const request = await makeRequest(`ressources`, 'GET', {});
diff --git a/frontend/stores/user.store.ts b/frontend/stores/user.store.ts
new file mode 100644
index 00000000..0e6c5861
--- /dev/null
+++ b/frontend/stores/user.store.ts
@@ -0,0 +1,19 @@
+import { defineStore } from 'pinia';
+import type { User } from './db_strustures'; // Assurez-vous d'avoir les bonnes définitions de types
+
+export const useUserStore = defineStore('user', {
+ state: () => ({
+ user: ref<User | null>(null),
+ }),
+ actions: {
+ fetch() {
+ return new Promise(async (resolve, reject) => {
+ const request = await makeRequest(`users/@me`, 'GET', {});
+ if (request.status === 'success') {
+ this.user = request.result as User;
+ return resolve(this.user);
+ } else reject(request.message);
+ });
+ },
+ },
+});
diff --git a/frontend/styles/main.scss b/frontend/styles/main.scss
index 50510d87..1ec73290 100644
--- a/frontend/styles/main.scss
+++ b/frontend/styles/main.scss
@@ -35,6 +35,16 @@
background-color: var(--selection-color);
}
+.modal-mask {
+ position: fixed;
+ z-index: 100;
+ top: 0;
+ left: 0;
+ width: 100vw;
+ height: 100vh;
+ background-color: rgba(0, 0, 0, 0.5);
+ display: flex;
+}
body {
background: var(--bg-color);