Ajusta portal do cliente e desbloqueia abertura de chamados

This commit is contained in:
Esdras Renan 2025-10-13 17:47:39 -03:00
parent 12c7fa23ae
commit 6a04ef4843
4 changed files with 34 additions and 9 deletions

View file

@ -18,7 +18,8 @@ interface CategorySelectProps {
categoryId: string | null
subcategoryId: string | null
onCategoryChange: (categoryId: string) => void
onSubcategoryChange: (subcategoryId: string) => void
onSubcategoryChange: (subcategoryId: string | null) => void
onSecondaryOptionsChange?: (hasSecondary: boolean) => void
autoSelectFirst?: boolean
disabled?: boolean
categoryLabel?: string
@ -39,6 +40,7 @@ export function CategorySelectFields({
subcategoryId,
onCategoryChange,
onSubcategoryChange,
onSecondaryOptionsChange,
autoSelectFirst = true,
disabled = false,
categoryLabel = "Primária",
@ -72,10 +74,22 @@ export function CategorySelectFields({
const first = secondaryOptions[0]
if (first) {
onSubcategoryChange(first.id)
} else {
onSubcategoryChange(null)
}
}
}, [categoryId, secondaryOptions, subcategoryId, onSubcategoryChange])
useEffect(() => {
onSecondaryOptionsChange?.(secondaryOptions.length > 0)
}, [secondaryOptions, onSecondaryOptionsChange])
useEffect(() => {
if (secondaryOptions.length === 0 && subcategoryId) {
onSubcategoryChange(null)
}
}, [secondaryOptions, subcategoryId, onSubcategoryChange])
const containerClass = layout === "stacked" ? "flex flex-col gap-3" : "grid gap-3 sm:grid-cols-2"
return (

View file

@ -112,7 +112,7 @@ export function NewTicketDialog() {
}
}
const handleSubcategoryChange = (value: string) => {
const handleSubcategoryChange = (value: string | null) => {
const previous = form.getValues("subcategoryId") ?? ""
const next = value ?? ""
form.setValue("subcategoryId", next, {