refactor(web): rename Organisation to Instance

This commit is contained in:
2026-07-24 14:01:19 +01:00
parent 3f0f12b111
commit b70ccc97d4
8 changed files with 76 additions and 76 deletions
+8 -8
View File
@@ -1,18 +1,18 @@
"use client";
import { createContext, useContext, useEffect, useState, ReactNode } from "react";
import { auth, type Org, type Role, type SessionUser } from "@/lib/api";
import { auth, type Instance, type Role, type SessionUser } from "@/lib/api";
export type { Org, Role, SessionUser };
export type { Instance, Role, SessionUser };
interface AuthContextType {
user: SessionUser | null;
org: Org | null;
/** True for owner and admin the roles the /api/settings and /api/org routes require. */
instance: Instance | null;
/** True for owner and admin the roles the /api/settings and /api/instance routes require. */
isAdmin: boolean;
}
const AuthContext = createContext<AuthContextType>({ user: null, org: null, isAdmin: false });
const AuthContext = createContext<AuthContextType>({ user: null, instance: null, isAdmin: false });
export function useAuth() {
return useContext(AuthContext);
@@ -24,7 +24,7 @@ export function useAuth() {
*/
export function AuthProvider({ children }: { children: ReactNode }) {
const [user, setUser] = useState<SessionUser | null>(null);
const [org, setOrg] = useState<Org | null>(null);
const [instance, setOrg] = useState<Instance | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -42,7 +42,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const me = await auth.me();
if (cancelled) return;
setUser(me.user);
setOrg(me.org);
setOrg(me.instance);
setLoading(false);
} catch (err) {
if (cancelled) return;
@@ -91,5 +91,5 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const isAdmin = user.role === "owner" || user.role === "admin";
return <AuthContext.Provider value={{ user, org, isAdmin }}>{children}</AuthContext.Provider>;
return <AuthContext.Provider value={{ user, instance, isAdmin }}>{children}</AuthContext.Provider>;
}