schlechtenburg/packages/example-site/composables/states.ts

56 lines
884 B
TypeScript

import { IBlockData } from "@schlechtenburg/core";
export interface IRole {
id?: string|null;
attributes?: {
description: string;
name: string;
};
}
export interface IUser {
id?: string|null;
attributes?: {
blocked?: boolean;
confirmed?: boolean;
email?: string;
role?: IRole;
username?: string;
};
}
export const useMe = () => {
const me = useState<IUser|null>('me', () => null);
const setMe = (user: IUser|null) => {
me.value = user;
};
return {
me,
setMe,
};
};
export interface IPage {
id?: string|null;
attributes?: {
title?: string;
block?: IBlockData<any>|null;
path?: string;
};
}
export const usePage = () => {
const page = useState<IPage|null>('page', () => null);
const setPage = (newPage: IPage|null) => {
page.value = newPage;
};
return {
page,
setPage,
};
};