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
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.
126 lines
3.4 KiB
TypeScript
126 lines
3.4 KiB
TypeScript
/**
|
|
* Create form for a new team workspace -> POST /workspaces. Just a name plus a
|
|
* submit; owns its own submitting/error state and clears on success. The parent
|
|
* performs the create (so it can prepend the new workspace to its list).
|
|
*/
|
|
|
|
import { useState } from "react";
|
|
import {
|
|
ActivityIndicator,
|
|
Pressable,
|
|
StyleSheet,
|
|
Text,
|
|
TextInput,
|
|
View,
|
|
} from "react-native";
|
|
|
|
import type { CreateWorkspaceRequest } from "@/lib/types";
|
|
|
|
import { describeError } from "@/components/me/errors";
|
|
import { colors } from "@/components/me/theme";
|
|
|
|
interface CreateWorkspaceFormProps {
|
|
/** Performs the create; resolves once the new workspace is in the list. */
|
|
onCreate: (body: CreateWorkspaceRequest) => Promise<void>;
|
|
}
|
|
|
|
export function CreateWorkspaceForm({ onCreate }: CreateWorkspaceFormProps) {
|
|
const [name, setName] = useState("");
|
|
const [submitting, setSubmitting] = useState(false);
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
const canSubmit = !!name.trim() && !submitting;
|
|
|
|
const onSubmit = async () => {
|
|
const trimmed = name.trim();
|
|
if (!trimmed) {
|
|
setError("Give your workspace a name.");
|
|
return;
|
|
}
|
|
setSubmitting(true);
|
|
setError(null);
|
|
try {
|
|
await onCreate({ name: trimmed });
|
|
setName("");
|
|
} catch (err) {
|
|
setError(describeError(err, "Failed to create workspace."));
|
|
} finally {
|
|
setSubmitting(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<View style={styles.card}>
|
|
<Text style={styles.label}>New workspace</Text>
|
|
<View style={styles.row}>
|
|
<TextInput
|
|
style={styles.input}
|
|
value={name}
|
|
onChangeText={(text) => {
|
|
setName(text);
|
|
if (error) setError(null);
|
|
}}
|
|
placeholder="e.g. Acme Studio"
|
|
placeholderTextColor={colors.muted}
|
|
editable={!submitting}
|
|
returnKeyType="done"
|
|
onSubmitEditing={() => {
|
|
if (canSubmit) void onSubmit();
|
|
}}
|
|
/>
|
|
<Pressable
|
|
style={[styles.button, !canSubmit && styles.buttonDisabled]}
|
|
onPress={onSubmit}
|
|
disabled={!canSubmit}
|
|
accessibilityRole="button"
|
|
accessibilityLabel="Create workspace"
|
|
accessibilityState={{ disabled: !canSubmit }}
|
|
>
|
|
{submitting ? (
|
|
<ActivityIndicator color={colors.textPrimary} />
|
|
) : (
|
|
<Text style={styles.buttonText}>Create</Text>
|
|
)}
|
|
</Pressable>
|
|
</View>
|
|
{error ? <Text style={styles.error}>{error}</Text> : null}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
card: {
|
|
backgroundColor: colors.card,
|
|
borderColor: colors.border,
|
|
borderWidth: 1,
|
|
borderRadius: 12,
|
|
padding: 14,
|
|
gap: 10,
|
|
},
|
|
label: { color: colors.textSecondary, fontSize: 13, fontWeight: "600" },
|
|
row: { flexDirection: "row", gap: 8, alignItems: "center" },
|
|
input: {
|
|
flex: 1,
|
|
backgroundColor: colors.bg,
|
|
borderColor: colors.border,
|
|
borderWidth: 1,
|
|
borderRadius: 10,
|
|
color: colors.textPrimary,
|
|
fontSize: 15,
|
|
paddingHorizontal: 12,
|
|
paddingVertical: 10,
|
|
},
|
|
button: {
|
|
backgroundColor: colors.primary,
|
|
borderRadius: 10,
|
|
paddingHorizontal: 18,
|
|
paddingVertical: 11,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
minWidth: 92,
|
|
},
|
|
buttonDisabled: { opacity: 0.5 },
|
|
buttonText: { color: colors.textPrimary, fontWeight: "700" },
|
|
error: { color: colors.error, fontSize: 13 },
|
|
});
|