feat: modernize report scheduling UI and date inputs
This commit is contained in:
parent
8cc513c532
commit
616fe42e10
10 changed files with 384 additions and 60 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"use client"
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, useTransition } from "react"
|
||||
import dynamic from "next/dynamic"
|
||||
import { Controller, FormProvider, useFieldArray, useForm, type UseFormReturn } from "react-hook-form"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import {
|
||||
|
|
@ -86,7 +87,8 @@ import { useAuth } from "@/lib/auth-client"
|
|||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import { api } from "@/convex/_generated/api"
|
||||
import { MultiValueInput } from "@/components/ui/multi-value-input"
|
||||
import { AdminDevicesOverview } from "@/components/admin/devices/admin-devices-overview"
|
||||
import { Spinner } from "@/components/ui/spinner"
|
||||
import { DatePicker } from "@/components/ui/date-picker"
|
||||
|
||||
type LastAlertInfo = { createdAt: number; usagePct: number; threshold: number } | null
|
||||
|
||||
|
|
@ -101,6 +103,22 @@ type EditorState =
|
|||
| { mode: "create" }
|
||||
| { mode: "edit"; company: NormalizedCompany }
|
||||
|
||||
const AdminDevicesOverview = dynamic(
|
||||
() =>
|
||||
import("@/components/admin/devices/admin-devices-overview").then(
|
||||
(mod) => mod.AdminDevicesOverview
|
||||
),
|
||||
{
|
||||
ssr: false,
|
||||
loading: () => (
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Spinner className="size-4" />
|
||||
<span>Carregando dispositivos...</span>
|
||||
</div>
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
const BOARD_COLUMNS = [
|
||||
{ id: "monthly", title: "Mensalistas", description: "Contratos recorrentes ou planos mensais." },
|
||||
{ id: "time_bank", title: "Banco de horas", description: "Clientes com consumo controlado por horas." },
|
||||
|
|
@ -1790,17 +1808,48 @@ function CompanySheet({ tenantId, editor, onClose, onCreated, onUpdated }: Compa
|
|||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Data de início</Label>
|
||||
<Input type="date" {...form.register(`contracts.${index}.startDate`)} />
|
||||
<Controller
|
||||
name={`contracts.${index}.startDate`}
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<DatePicker
|
||||
value={field.value}
|
||||
onChange={(next) => field.onChange(next ?? null)}
|
||||
placeholder="Selecionar data"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<FieldError error={fieldErrors?.startDate?.message as string | undefined} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Data de fim</Label>
|
||||
<Input type="date" {...form.register(`contracts.${index}.endDate`)} />
|
||||
<Controller
|
||||
name={`contracts.${index}.endDate`}
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<DatePicker
|
||||
value={field.value}
|
||||
onChange={(next) => field.onChange(next ?? null)}
|
||||
placeholder="Selecionar data"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<FieldError error={fieldErrors?.endDate?.message as string | undefined} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Renovação</Label>
|
||||
<Input type="date" {...form.register(`contracts.${index}.renewalDate`)} />
|
||||
<Controller
|
||||
name={`contracts.${index}.renewalDate`}
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<DatePicker
|
||||
value={field.value}
|
||||
onChange={(next) => field.onChange(next ?? null)}
|
||||
placeholder="Selecionar data"
|
||||
allowClear
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Valor mensal/projeto</Label>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue