- Add drag-to-resize sidebar with localStorage persistence - Rewrite issue detail page with Tiptap rich text editor, due date picker, acceptance criteria - Redesign create-issue modal with pill-based property toolbar and expand/collapse - Consolidate @multica/sdk and @multica/types into apps/web/shared/ - Simplify auth: remove verification codes, PATs, email service (dev-only login) - Add 401 unauthorized handler to redirect expired sessions to login - Fix due date format to send full RFC3339 timestamps - Increase description editor debounce to 1500ms - Remove arbitrary Tailwind values in create-issue modal - Renumber migrations (inbox_actor 012→009), remove unused migrations - UI polish across agents, settings, inbox, knowledge-base pages Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { create } from "zustand";
|
|
import type { User } from "@/shared/types";
|
|
import { api } from "@/shared/api";
|
|
|
|
interface AuthState {
|
|
user: User | null;
|
|
isLoading: boolean;
|
|
|
|
initialize: () => Promise<void>;
|
|
login: (email: string, name?: string) => Promise<User>;
|
|
logout: () => void;
|
|
setUser: (user: User) => void;
|
|
}
|
|
|
|
export const useAuthStore = create<AuthState>((set) => ({
|
|
user: null,
|
|
isLoading: true,
|
|
|
|
initialize: async () => {
|
|
const token = localStorage.getItem("multica_token");
|
|
if (!token) {
|
|
set({ isLoading: false });
|
|
return;
|
|
}
|
|
|
|
api.setToken(token);
|
|
|
|
try {
|
|
const user = await api.getMe();
|
|
set({ user, isLoading: false });
|
|
} catch {
|
|
api.setToken(null);
|
|
api.setWorkspaceId(null);
|
|
localStorage.removeItem("multica_token");
|
|
localStorage.removeItem("multica_workspace_id");
|
|
set({ user: null, isLoading: false });
|
|
}
|
|
},
|
|
|
|
login: async (email: string, name?: string) => {
|
|
const { token, user } = await api.login(email, name);
|
|
localStorage.setItem("multica_token", token);
|
|
api.setToken(token);
|
|
set({ user });
|
|
return user;
|
|
},
|
|
|
|
logout: () => {
|
|
localStorage.removeItem("multica_token");
|
|
localStorage.removeItem("multica_workspace_id");
|
|
api.setToken(null);
|
|
api.setWorkspaceId(null);
|
|
set({ user: null });
|
|
},
|
|
|
|
setUser: (user: User) => {
|
|
set({ user });
|
|
},
|
|
}));
|