teqo-backup/src/app/(frontend)/actions/getSignatureCount.ts
Francisco Ignácio Fontoura Solla a862d0c582 feat: Add signature counter and display
Integrate a real-time signature counter component into petition pages.
This includes:

- A new `SignatureCounter` component that displays and animates the
  signature count.
- Server action `getSignatureCount` to fetch current signatures from
  Payload.
- Updates to `submitPetitionSignature` to return the signature number
  for immediate display.
- Event listeners for real-time updates when new signatures are
  submitted.
- Integration of the counter into both the hero section and card views
  of the petition page.
- Improved dialog for displaying signature success and number.
2026-05-01 01:51:07 -03:00

15 lines
370 B
TypeScript

'use server'
import config from '@payload-config'
import { getPayload } from 'payload'
export const getSignatureCount = async (petitionId: string): Promise<number> => {
const payload = await getPayload({ config })
const { totalDocs } = await payload.count({
collection: 'signature',
where: { petition: { equals: petitionId } },
})
return totalDocs
}