videogen/apps/mobile/components/team/WorkspaceSelect.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

88 lines
2.7 KiB
TypeScript

/**
* A single-select "charge to / share with" chip row: a leading "Personal" chip
* (value `null`) followed by one chip per workspace the caller belongs to.
* Purely presentational — the parent owns the selection and the workspace list.
*
* Used by the Create screen ("Charge to" — Personal vs a workspace's shared
* credit pool) and the Presets form ("Share to team" — keep personal vs share a
* brand kit to a workspace).
*/
import { Pressable, StyleSheet, Text, View } from "react-native";
import type { Workspace } from "@/lib/types";
import { colors } from "@/components/me/theme";
export interface WorkspaceSelectProps {
/** Workspaces the caller can pick (typically GET /workspaces). */
workspaces: readonly Workspace[];
/** Selected workspace id, or `null` for the "Personal" option. */
value: string | null;
/** Called with the picked workspace id, or `null` for "Personal". */
onSelect: (workspaceId: string | null) => void;
disabled?: boolean;
/** Label for the leading personal chip (defaults to "Personal"). */
personalLabel?: string;
}
export function WorkspaceSelect({
workspaces,
value,
onSelect,
disabled = false,
personalLabel = "Personal",
}: Readonly<WorkspaceSelectProps>) {
const options: { id: string | null; label: string }[] = [
{ id: null, label: personalLabel },
...workspaces.map((w) => ({ id: w.id, label: w.name })),
];
return (
<View style={styles.wrap}>
{options.map((option) => {
const active = option.id === value;
return (
<Pressable
key={option.id ?? "__personal__"}
style={[
styles.chip,
active && styles.chipActive,
disabled && styles.chipDisabled,
]}
onPress={() => onSelect(option.id)}
disabled={disabled}
accessibilityRole="radio"
accessibilityState={{ selected: active, disabled }}
accessibilityLabel={option.label}
>
<Text
style={[styles.chipText, active && styles.chipTextActive]}
numberOfLines={1}
>
{option.label}
</Text>
</Pressable>
);
})}
</View>
);
}
const styles = StyleSheet.create({
wrap: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
chip: {
backgroundColor: colors.card,
borderColor: colors.border,
borderWidth: 1,
borderRadius: 999,
paddingHorizontal: 14,
paddingVertical: 8,
maxWidth: 220,
},
chipActive: { backgroundColor: colors.primary, borderColor: colors.primary },
chipDisabled: { opacity: 0.5 },
chipText: { color: colors.textSecondary, fontSize: 13 },
chipTextActive: { color: colors.textPrimary, fontWeight: "700" },
});