import { get } from './utils';

export type Flair = {
    id: string;
    user_id: string;
    color: string;
    name: string;
    expr: string;
    description: string;
    showFullDescription: number;
    sort: number;
};

function createFlairStore() {
    let flairList: Flair[] = $state([]);

    return {
        get flairs() {
            return flairList;
        },

        async loadItems(force?: boolean) {
            if (flairList.length > 0 && !force) {
                return;
            }
            flairList = await get('flair/');
        }
    };
}

export const flairStore = createFlairStore();
