first commit
CI/CD / CI · Admin API (dotnet build) (push) Successful in 41s
CI/CD / CI · Admin Web (tsc) (push) Failing after 5s
CI/CD / CI · Website (tsc) (push) Failing after 4s
CI/CD / CI · Koja (tsc) (push) Failing after 5s
CI/CD / CI · API (dotnet build + test) (push) Successful in 1m13s
CI/CD / CI · Dashboard (tsc) (push) Failing after 2m32s
CI/CD / Deploy · all services (push) Has been skipped
CI/CD / CI · Admin API (dotnet build) (push) Successful in 41s
CI/CD / CI · Admin Web (tsc) (push) Failing after 5s
CI/CD / CI · Website (tsc) (push) Failing after 4s
CI/CD / CI · Koja (tsc) (push) Failing after 5s
CI/CD / CI · API (dotnet build + test) (push) Successful in 1m13s
CI/CD / CI · Dashboard (tsc) (push) Failing after 2m32s
CI/CD / Deploy · all services (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { apiGet, apiPost, apiPatch, apiDelete } from "@/lib/api/client";
|
||||
import type { AuthTokenResponse } from "@/lib/api/types";
|
||||
|
||||
export interface BranchRoleAssignment {
|
||||
id: string;
|
||||
branchId: string;
|
||||
branchName: string;
|
||||
role: string;
|
||||
}
|
||||
|
||||
export function listBranchRoles(cafeId: string, employeeId: string) {
|
||||
return apiGet<BranchRoleAssignment[]>(
|
||||
`/api/cafes/${cafeId}/employees/${employeeId}/branch-roles`
|
||||
);
|
||||
}
|
||||
|
||||
export function assignBranchRole(
|
||||
cafeId: string,
|
||||
employeeId: string,
|
||||
body: { branchId: string; role: string }
|
||||
) {
|
||||
return apiPost<BranchRoleAssignment, typeof body>(
|
||||
`/api/cafes/${cafeId}/employees/${employeeId}/branch-roles`,
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
export function updateBranchRole(
|
||||
cafeId: string,
|
||||
employeeId: string,
|
||||
assignmentId: string,
|
||||
role: string
|
||||
) {
|
||||
return apiPatch<BranchRoleAssignment, { role: string }>(
|
||||
`/api/cafes/${cafeId}/employees/${employeeId}/branch-roles/${assignmentId}`,
|
||||
{ role }
|
||||
);
|
||||
}
|
||||
|
||||
export function removeBranchRole(
|
||||
cafeId: string,
|
||||
employeeId: string,
|
||||
assignmentId: string
|
||||
) {
|
||||
return apiDelete(
|
||||
`/api/cafes/${cafeId}/employees/${employeeId}/branch-roles/${assignmentId}`
|
||||
);
|
||||
}
|
||||
|
||||
/** Re-issue the session token scoped to a branch (null = café-wide, Owner only). */
|
||||
export function switchBranch(branchId: string | null) {
|
||||
return apiPost<AuthTokenResponse, { branchId: string | null }>(
|
||||
`/api/auth/switch-branch`,
|
||||
{ branchId }
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,12 @@ export interface CafeMembership {
|
||||
planTier: string;
|
||||
}
|
||||
|
||||
export interface BranchMembership {
|
||||
branchId: string;
|
||||
branchName: string;
|
||||
role: string;
|
||||
}
|
||||
|
||||
export interface AuthTokenResponse {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
@@ -23,6 +29,14 @@ export interface AuthTokenResponse {
|
||||
actor?: string;
|
||||
branchId?: string | null;
|
||||
memberships?: CafeMembership[] | null;
|
||||
/** Display name of the currently active branch (null when café-wide). */
|
||||
branchName?: string | null;
|
||||
/** True when the session spans the whole café (Owner, no branch scope). */
|
||||
isCafeWide?: boolean;
|
||||
/** Branches this employee may operate as, with their role in each. */
|
||||
branches?: BranchMembership[] | null;
|
||||
/** Effective capabilities for the active role — drives page/action gating. */
|
||||
permissions?: string[] | null;
|
||||
}
|
||||
|
||||
/** Returned (in the data field) when a phone belongs to multiple cafés. */
|
||||
|
||||
Reference in New Issue
Block a user