Skip to content

[Hacktoberfest][Web2.0] Implement observer guides CRUD in new UI - #1013

Open
cristian-ist wants to merge 2 commits into
commitglobal:feature/frontend2.0-hackdayfrom
cristian-ist:votemonitor-1005
Open

[Hacktoberfest][Web2.0] Implement observer guides CRUD in new UI#1013
cristian-ist wants to merge 2 commits into
commitglobal:feature/frontend2.0-hackdayfrom
cristian-ist:votemonitor-1005

Conversation

@cristian-ist

@cristian-ist cristian-ist commented Oct 8, 2025

Copy link
Copy Markdown

Summary

Implements full CRUD for observer guides in the new admin UI (web2.0), following
the flow of the existing admin app but built on the web2.0 structure and
components.

Closes #1005

What's included

Create — an "Upload observer guide" dropdown offers the three guide types
(Document / Url / Text). The type is picked before the dialog opens because it
cannot be changed afterwards and it decides which fields the form shows. The
dialog renders only the relevant field: a file input, a url input, or a textarea.
The request goes out as multipart and only sends the field matching the selected
type, since the backend feeds WebsiteUrl straight into new Uri(...).

Read — the table shows a type icon (paperclip / link / document), title,
formatted upload date and author, with search, a guide type filter, sorting and
pagination.

Update — a dialog with the title plus the url or the text, depending on the
type. Document guides only expose their title: the API keeps the uploaded file
as it is and offers no way to replace it.

Delete — a destructive confirmation dialog naming the guide.

Row actions are disabled for guides received through a coalition
(isGuideOwner: false), which the API resolves only for their owner. The upload
button is disabled on archived election rounds.

Client side validation mirrors the API validators: title required and capped at
256 characters, url capped at 2048 and required to be absolute, text required,
attachment capped at 50 MB.

Fixes to the earlier commit on this branch

The previous commit only added a listing, and it no longer built against the
current state of the branch:

  • the page called useListMonitoringObservers instead of the guides query, with
    a @ts-ignore hiding the mismatch
  • validateSearch used zodValidator from @tanstack/zod-adapter, a package no
    longer present in package.json; every other route passes the zod schema
    directly
  • imports pointed at @/components/data-table-toolbar and
    @/components/data-table-column-header, which have since moved under
    @/components/data-table/
  • the initial sort referenced displayName, a column that does not exist on the
    guide model
  • the response was typed as PageResponse<T> while the endpoint answers with
    { guides: [...] }, so data.items was always undefined
  • the row action state was written but never read, leaving Edit and Delete inert
  • the filter reset was a console.log placeholder
  • urlValidityInSeconds was typed as string although the API returns an int,
    and guideAccess was missing from the model

Implementation notes

The list endpoint takes nothing but the election round id — no filtering, no
sorting, no pagination, as noted in the issue. Filtering, sorting and paging are
therefore computed client side over the full list and the resulting slice is
handed to the table, which keeps the same DataTable, toolbar and pagination as
the rest of the app. The query key holds only the election round id, so typing in
the search box no longer refetches an identical payload.

No shared or unrelated file was touched: the changes are limited to the guides
types, api layer, query, mutations, page and route.

Out of scope

Guide access (coalition sharing), document download through presignedUrl, and a
read only view for text guides are left out — the issue asks for CRUD. As a
consequence a text guide can currently only be read by opening its update dialog,
and documents cannot be downloaded from the UI. The generated
guides/$guideId.tsx route is left untouched as well, since removing it would
require regenerating the route tree.

Verification

  • tsc reports no errors in the guides code
  • eslint reports no errors beyond the repo wide react/react-in-jsx-scope rule,
    which fires across the whole project
  • prettier --check passes
  • knip reports nothing unused

@vercel

vercel Bot commented Oct 8, 2025

Copy link
Copy Markdown

@cristian-ist is attempting to deploy a commit to the Code for Romania Team on Vercel.

A member of the Team first needs to authorize it.

@cristian-ist
cristian-ist changed the base branch from main to feature/frontend2.0-hackday October 8, 2025 11:20
@cristian-ist cristian-ist changed the title Votemonitor 1005 [Hacktoberfest][Web2.0] Implement forms CRUD in new UI Oct 8, 2025
@cristian-ist cristian-ist changed the title [Hacktoberfest][Web2.0] Implement forms CRUD in new UI Implement forms CRUD in new UI Oct 8, 2025
@cristian-ist
cristian-ist marked this pull request as ready for review August 12, 2026 05:16
@cristian-ist cristian-ist changed the title Implement forms CRUD in new UI [Hacktoberfest][Web2.0] Implement observer guides CRUD in new UI Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants