- ~190 findings zerados: knip --fix (grafo corrigido: tests como entries, migrations como consumidores) + delecao guardada dos orfaos (git grep -w antes de deletar) + reparos manuais dos corpos arrow pendurados - pecas nao usadas do kit ui deletadas (PaginationLink/Next/Previous, familias Sidebar/Combobox/Sheet/Drawer/Dialog etc.) - shadcn add recoloca se precisar - acoes mortas removidas (updateCampaignDemandDetails*, *Record orfaos), schemas/tipos mortos (campaignDemandDetailsUpdateSchema, Contact do zod), helpers mortos - tipos de eleicao derivam direto das *_OPTIONS (consts intermediarias eliminadas) - knip.json: rules exports/types/enumMembers=error, duplicates=off (unicos hits: 6 aliases deliberados canUpdateX=canReadX); hints aplicados (payload.config entry redundante, ignores de tsx/sharp/playwright/payload-types desnecessarios) - ledger: linha P2 dos unused exports fechada
30 lines
827 B
TypeScript
30 lines
827 B
TypeScript
import { revalidatePath } from 'next/cache'
|
|
|
|
type MunicipalityListRevalidateScope = 'list' | 'detail' | 'both'
|
|
|
|
const municipalitySlugPathPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
|
|
|
|
type RevalidateMunicipalityListPathsOptions = {
|
|
slug?: string
|
|
scope?: MunicipalityListRevalidateScope
|
|
}
|
|
|
|
export const revalidateMunicipalityListPaths = ({
|
|
slug,
|
|
scope = 'both',
|
|
}: RevalidateMunicipalityListPathsOptions = {}) => {
|
|
const detailSlug = slug && municipalitySlugPathPattern.test(slug) ? slug : undefined
|
|
|
|
if (scope === 'list' || scope === 'both') {
|
|
revalidatePath('/campanha/municipios', 'page')
|
|
}
|
|
|
|
if (scope === 'detail' || scope === 'both') {
|
|
if (detailSlug) {
|
|
revalidatePath(`/campanha/municipios/${detailSlug}`, 'page')
|
|
return
|
|
}
|
|
|
|
revalidatePath('/campanha/municipios/[slug]', 'page')
|
|
}
|
|
}
|