JUMBO refactor, still work in progress
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { UserId } from "common";
|
||||
import { type Me } from "common/the_api";
|
||||
import { identity } from "effect";
|
||||
import { useLayoutEffect, useState } from "react";
|
||||
|
||||
@@ -9,23 +9,15 @@ export const mapProp = <const K extends string, T>(prop: K, action: Update<T>) =
|
||||
return Object.freeze({ ...object, [prop]: typeof action === "function" ? (action as (prev: T) => T)(object[prop]) : action });
|
||||
};
|
||||
|
||||
export namespace Store {
|
||||
export interface User {
|
||||
readonly userId: UserId;
|
||||
readonly username: string;
|
||||
readonly roles: readonly string[];
|
||||
}
|
||||
}
|
||||
|
||||
export interface Store {
|
||||
readonly user: Store.User | null;
|
||||
readonly user: Me | null;
|
||||
}
|
||||
|
||||
let store: Store = Object.freeze<Store>({
|
||||
user: null,
|
||||
});
|
||||
|
||||
export function setUser(action: Update<Store.User | null>) {
|
||||
export function setUser(action: Update<Me | null>) {
|
||||
set(mapProp("user", action));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user