Reverte opcionalidade de subcategoria no portal
This commit is contained in:
parent
6a04ef4843
commit
9f85cbaba5
3 changed files with 7 additions and 31 deletions
|
|
@ -18,8 +18,7 @@ interface CategorySelectProps {
|
|||
categoryId: string | null
|
||||
subcategoryId: string | null
|
||||
onCategoryChange: (categoryId: string) => void
|
||||
onSubcategoryChange: (subcategoryId: string | null) => void
|
||||
onSecondaryOptionsChange?: (hasSecondary: boolean) => void
|
||||
onSubcategoryChange: (subcategoryId: string) => void
|
||||
autoSelectFirst?: boolean
|
||||
disabled?: boolean
|
||||
categoryLabel?: string
|
||||
|
|
@ -40,7 +39,6 @@ export function CategorySelectFields({
|
|||
subcategoryId,
|
||||
onCategoryChange,
|
||||
onSubcategoryChange,
|
||||
onSecondaryOptionsChange,
|
||||
autoSelectFirst = true,
|
||||
disabled = false,
|
||||
categoryLabel = "Primária",
|
||||
|
|
@ -80,16 +78,6 @@ export function CategorySelectFields({
|
|||
}
|
||||
}, [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 (
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export function NewTicketDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
const handleSubcategoryChange = (value: string | null) => {
|
||||
const handleSubcategoryChange = (value: string) => {
|
||||
const previous = form.getValues("subcategoryId") ?? ""
|
||||
const next = value ?? ""
|
||||
form.setValue("subcategoryId", next, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue