videogen/apps/mobile/components/team/EnterpriseMemberRow.tsx
caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

89 lines
2.7 KiB
TypeScript

/**
* One member row in the ENTERPRISE roster. Presentation only — all state and
* handlers are owned by the parent. Role-aware:
*
* - Every row shows the member's email + Enterprise role.
* - When the caller can manage members AND this row is not the caller, an inline
* {@link EnterpriseRolePicker} lets them change the role — capped at their own
* rank (`callerRank`) so a chip that would out-rank the caller is disabled.
* - The caller's own row is marked "You" and is never editable here (a caller
* changes their own standing by leaving, on the workspace screen).
*
* Roles are keyed by `user_id` (the RBAC endpoints' path param), not a
* membership row id.
*/
import { StyleSheet, Text, View } from "react-native";
import type { EnterpriseRole, WorkspaceMember } from "@/lib/types";
import { colors } from "@/components/me/theme";
import { EnterpriseRolePicker } from "./EnterpriseRolePicker";
import { roleLabel } from "./roles";
export interface EnterpriseMemberRowProps {
member: WorkspaceMember;
/** True when this row is the calling user. */
isSelf: boolean;
/** True when the caller may change roles (holds `members.manage`). */
canManage: boolean;
/** The caller's own rank; roles above it are shown disabled in the picker. */
callerRank: number;
/** True while a role change targeting this row is in flight. */
busy: boolean;
onSetRole: (member: WorkspaceMember, role: EnterpriseRole) => void;
}
export function EnterpriseMemberRow({
member,
isSelf,
canManage,
callerRank,
busy,
onSetRole,
}: Readonly<EnterpriseMemberRowProps>) {
const showControls = canManage && !isSelf;
return (
<View style={styles.card}>
<View style={styles.headerRow}>
<Text style={styles.email} numberOfLines={1}>
{member.email || member.user_id}
</Text>
{isSelf ? <Text style={styles.selfBadge}>You</Text> : null}
</View>
{showControls ? (
<EnterpriseRolePicker
selected={member.role}
onSelect={(role) => onSetRole(member, role)}
disabled={busy}
maxRank={callerRank}
/>
) : (
<Text style={styles.roleBadge}>{roleLabel(member.role)}</Text>
)}
</View>
);
}
const styles = StyleSheet.create({
card: {
backgroundColor: colors.card,
borderColor: colors.border,
borderWidth: 1,
borderRadius: 12,
padding: 14,
gap: 12,
},
headerRow: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
gap: 12,
},
email: { color: colors.textPrimary, fontSize: 15, fontWeight: "600", flex: 1 },
selfBadge: { color: colors.accent, fontSize: 12, fontWeight: "700" },
roleBadge: { color: colors.textSecondary, fontSize: 13, fontWeight: "700" },
});