update lisensi prosess
tests / ci (push) Has been cancelled

This commit is contained in:
Wian Drs
2026-08-25 13:43:55 +07:00
parent 1e80be180e
commit 60946ddf37
58 changed files with 2903 additions and 165 deletions
@@ -11,7 +11,14 @@ import {
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
export default function TenantCreate() {
export default function TenantCreate({
plans,
}: {
plans: Record<
string,
{ name: string; price: number; max_devices: number; max_users: number }
>;
}) {
return (
<>
<Head title="Tambah Tenant" />
@@ -158,6 +165,34 @@ export default function TenantCreate() {
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">
@@ -33,15 +33,29 @@ type Installation = {
status: string;
last_seen_at?: string;
};
type License = {
plan: string;
status: string;
max_devices: number;
max_users: number;
expires_at: string;
};
export default function TenantEdit({
tenant,
users,
installation,
license,
plans,
}: {
tenant: Tenant;
users: User[];
installation: Installation | null;
license: License | null;
plans: Record<
string,
{ name: string; price: number; max_devices: number; max_users: number }
>;
}) {
const { flash } = usePage().props as unknown as {
flash: { success?: string };
@@ -150,6 +164,37 @@ export default function TenantEdit({
}
/>
</div>
<div className="grid gap-2 md:col-span-2">
<Label>Paket Lisensi Aktif</Label>
<select
name="plan_code"
defaultValue={
license?.plan ?? '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>
<p className="text-xs text-muted-foreground">
Status: {license?.status ?? 'belum ada'}
{license?.expires_at
? ` · sampai ${new Date(license.expires_at).toLocaleDateString('id-ID')}`
: ''}
</p>
<InputError message={errors.plan_code} />
</div>
<div className="flex gap-3 md:col-span-2">
<Button disabled={processing}>
Simpan Perubahan
@@ -17,6 +17,7 @@ type Tenant = {
domain?: string;
status: string;
}[];
licenses: { plan: string; status: string; expires_at: string }[];
};
type PageLink = { url: string | null; label: string; active: boolean };
type Props = { tenants: { data: Tenant[]; links: PageLink[]; total: number } };
@@ -62,6 +63,7 @@ export default function TenantIndex({ tenants }: Props) {
<th className="py-3">Tenant</th>
<th>Status</th>
<th>Instalasi</th>
<th>Paket</th>
<th>Users</th>
<th>Dibuat</th>
<th className="text-right">Aksi</th>
@@ -94,6 +96,16 @@ export default function TenantIndex({ tenants }: Props) {
: 'Nonaktif'}
</Badge>
</td>
<td>
<div className="font-medium">
{tenant.licenses[0]?.plan ??
'-'}
</div>
<div className="text-xs text-muted-foreground">
{tenant.licenses[0]?.status ??
'belum ada'}
</div>
</td>
<td>
<div className="font-medium">
{tenant.installations[0]
@@ -139,7 +151,7 @@ export default function TenantIndex({ tenants }: Props) {
{tenants.data.length === 0 && (
<tr>
<td
colSpan={6}
colSpan={7}
className="py-12 text-center text-muted-foreground"
>
Belum ada tenant. Buat tenant