Files
device-management/resources/js/pages/administration/tenants/create.tsx
T
Wian Drs 60946ddf37
tests / ci (push) Has been cancelled
update lisensi prosess
2026-08-25 13:43:55 +07:00

222 lines
11 KiB
TypeScript

import { Form, Head, Link } from '@inertiajs/react';
import InputError from '@/components/input-error';
import { Button } from '@/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
export default function TenantCreate({
plans,
}: {
plans: Record<
string,
{ name: string; price: number; max_devices: number; max_users: number }
>;
}) {
return (
<>
<Head title="Tambah Tenant" />
<div className="mx-auto flex w-full max-w-4xl flex-1 flex-col gap-6 p-4 md:p-6">
<div>
<h1 className="text-2xl font-semibold">Tambah Tenant</h1>
<p className="text-sm text-muted-foreground">
Tenant Owner pertama dibuat dalam transaksi yang sama.
</p>
</div>
<Form
action="/administration/tenants"
method="post"
resetOnSuccess
className="space-y-6"
>
{({ processing, errors }) => (
<>
<Card>
<CardHeader>
<CardTitle>Informasi Tenant</CardTitle>
<CardDescription>
Identitas organisasi pada platform.
</CardDescription>
</CardHeader>
<CardContent className="grid gap-5 md:grid-cols-2">
<div className="grid gap-2">
<Label htmlFor="name">
Nama Tenant
</Label>
<Input id="name" name="name" required />
<InputError message={errors.name} />
</div>
<div className="grid gap-2">
<Label htmlFor="slug">Slug</Label>
<Input
id="slug"
name="slug"
required
placeholder="isp-jakarta"
/>
<InputError message={errors.slug} />
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Tenant Owner</CardTitle>
<CardDescription>
Akun administrator utama khusus tenant
ini.
</CardDescription>
</CardHeader>
<CardContent className="grid gap-5 md:grid-cols-2">
<div className="grid gap-2">
<Label htmlFor="owner_name">
Nama Lengkap
</Label>
<Input
id="owner_name"
name="owner_name"
required
/>
<InputError
message={errors.owner_name}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="owner_email">
Email
</Label>
<Input
id="owner_email"
name="owner_email"
type="email"
required
/>
<InputError
message={errors.owner_email}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="owner_password">
Password
</Label>
<Input
id="owner_password"
name="owner_password"
type="password"
required
/>
<InputError
message={errors.owner_password}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="owner_password_confirmation">
Konfirmasi Password
</Label>
<Input
id="owner_password_confirmation"
name="owner_password_confirmation"
type="password"
required
/>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Lokasi Instalasi</CardTitle>
<CardDescription>
Tentukan apakah tenant bergabung di
cloud RADIQ atau menjalankan server
sendiri.
</CardDescription>
</CardHeader>
<CardContent className="grid gap-5 md:grid-cols-2">
<div className="grid gap-2">
<Label>Deployment</Label>
<select
name="deployment_type"
defaultValue="managed_cloud"
className="h-10 rounded-md border bg-background px-3"
>
<option value="managed_cloud">
Bergabung dengan RADIQ NDM Cloud
</option>
<option value="self_hosted">
Server/VPS/Komputer Tenant
</option>
</select>
<InputError
message={errors.deployment_type}
/>
</div>
<div className="grid gap-2">
<Label>Domain / Alamat Instalasi</Label>
<Input
name="deployment_domain"
placeholder="ndm.isp-example.co.id"
/>
<InputError
message={errors.deployment_domain}
/>
</div>
<div className="grid gap-2 md:col-span-2">
<Label>Paket Lisensi</Label>
<select
name="plan_code"
defaultValue="cloud_free"
className="h-10 rounded-md border bg-background px-3"
>
{Object.entries(plans).map(
([code, plan]) => (
<option
key={code}
value={code}
>
{plan.name} ·{' '}
{plan.price === 0
? 'Gratis'
: `Rp${plan.price.toLocaleString('id-ID')}/bulan`}{' '}
· {plan.max_devices}{' '}
perangkat ·{' '}
{plan.max_users} user
</option>
),
)}
</select>
<InputError
message={errors.plan_code}
/>
</div>
</CardContent>
</Card>
<div className="flex justify-end gap-3">
<Button variant="outline" asChild>
<Link href="/administration/tenants">
Batal
</Link>
</Button>
<Button disabled={processing}>
Buat Tenant
</Button>
</div>
</>
)}
</Form>
</div>
</>
);
}
TenantCreate.layout = {
breadcrumbs: [
{ title: 'Tenants', href: '/administration/tenants' },
{ title: 'Tambah', href: '/administration/tenants/create' },
],
};