Skip to content

Conversation

@pixelsama
Copy link
Contributor

Important

  1. Read CONTRIBUTING.md
  2. Ensure issue exists and you're assigned
  3. Link correctly: Fixes #<issue number>

What & Why

What: Added user notifications page filters/search/sort/unread toggle, admin notifications CRUD UI (list + bulk delete + create/edit form), mobile sidebar layout for notifications, and full i18n coverage for notification pages/forms.
Why: Completes the minimal notification center UX (user filters, admin management) and aligns with multilingual UI expectations.

Fixes #N/A

Pre-PR Checklist

Run these:

  • pnpm type-check
  • pnpm format:check
  • pnpm lint
  • pnpm build
  • pnpm i18n:check (if applicable)

Type

  • 🐛 Bug fix
  • ✨ Feature
  • 💥 Breaking change
  • 📚 Docs
  • ♻️ Refactor
  • ⚡ Performance

Screenshots (if UI changes)

N/A

@vercel
Copy link

vercel bot commented Nov 23, 2025

@pixelsama is attempting to deploy a commit to the zhang's projects Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Nov 23, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pixelsama, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the notification system by providing robust management tools for administrators and improved user experience for end-users. Administrators can now easily create, modify, and remove notifications through a dedicated UI, while users benefit from advanced filtering and sorting options to better manage their notification feed. The changes also ensure the notification interface is fully responsive and localized for a global audience.

Highlights

  • Admin Notification Management UI: Introduced a comprehensive administrative interface for managing notifications, enabling CRUD (Create, Read, Update, Delete) operations, including bulk deletion of notifications.
  • User Notification Filters and Sorting: Enhanced the user-facing notification page with new filtering capabilities (search, unread toggle) and sorting options (by creation date or priority).
  • Mobile Layout for Notifications: Implemented a responsive mobile sidebar layout specifically for the notifications section, improving accessibility on smaller screens.
  • Internationalization (i18n) Coverage: Added full internationalization support for all new notification-related pages and forms, ensuring the UI is adaptable to multiple languages.
  • Backend Search Functionality: Extended the backend API to support searching notifications by title and content, which powers the new frontend search features for both admin and user interfaces.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added area:ui UI components, layouts, styling, accessibility. type:feature Request for a brand-new capability. labels Nov 23, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive admin UI for managing notifications, including CRUD operations and bulk actions. It also enhances the user-facing notifications page with filtering, sorting, and search capabilities. The changes are well-structured, with new components for the admin form and pages. My review focuses on improving the data fetching logic for consistency and performance, avoiding redundant operations, and ensuring backend search capabilities match the frontend's intent. I've identified a couple of bugs related to data fetching that could lead to stale data or unnecessary API calls, and suggested ways to align the implementation with best practices already present in other parts of the codebase.

Comment on lines 92 to 95
useEffect(() => {
void fetchData();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This useEffect hook is configured to run only on component mount due to its empty dependency array. However, the fetchData function it calls depends on the sortBy and sortOrder state variables. When a user changes the sort order, fetchData is not re-executed, leading to a disconnect between the UI controls and the data fetched from the server. The client-side sorting then re-sorts the existing data, which is inefficient.

To fix this, you should include sortBy and sortOrder in the dependency array to ensure data is refetched when sorting options change. It would also be beneficial to wrap fetchData in a useCallback hook.

Suggested change
useEffect(() => {
void fetchData();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
void fetchData();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sortBy, sortOrder]);

Comment on lines 97 to 109
const handleIncludeReadToggle = useCallback(
(checked: boolean) => {
setIncludeRead(checked);
// When turning off includeRead, ensure we re-fetch unread-only
void fetchNotifications({
search: search.trim() || undefined,
sort_by: sortBy,
sort_order: sortOrder,
include_read: checked,
});
},
[fetchNotifications, search, sortBy, sortOrder]
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This handleIncludeReadToggle function explicitly calls fetchNotifications. However, the useEffect hook at lines 57-68 already triggers fetchNotifications whenever includeRead changes. This results in a redundant API call, as fetchNotifications will be called once from here and then again (after a 200ms delay) from the useEffect. You should remove the explicit call to fetchNotifications from this useCallback to avoid the double fetch.

  const handleIncludeReadToggle = useCallback(
    (checked: boolean) => {
      setIncludeRead(checked);
    },
    []
  );

Comment on lines 41 to 48
const [form, setForm] = useState({
type: 'message' as NotificationType,
category: '',
title: '',
content: '',
priority: 'medium' as NotificationPriority,
published: false,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The initial state for the form is defined here and then hardcoded again in the handleSubmit function (lines 108-115) to reset the form after creation. To avoid this duplication and improve maintainability, you could define the initial state in a constant outside the component and reuse it in both places.

For example:

const INITIAL_FORM_STATE = {
  type: 'message' as NotificationType,
  category: '',
  title: '',
  content: '',
  priority: 'medium' as NotificationPriority,
  published: false,
};

export function NotificationForm(...) {
  // ...
  const [form, setForm] = useState(INITIAL_FORM_STATE);
  // ...
  const handleSubmit = async (e: React.FormEvent) => {
    // ...
    if (mode === 'create') {
      // ...
      setForm(INITIAL_FORM_STATE);
    }
    // ...
  }
}


if (params.search) {
const term = `%${params.search}%`;
query = query.or(`title.ilike.${term},content.ilike.${term}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The search functionality on the frontend includes searching by category. To ensure consistent behavior and support a full server-side search, the category field should also be included in this search query. The category column is nullable, but ilike on a null value will evaluate to false in a WHERE clause, which is the desired behavior here.

Suggested change
query = query.or(`title.ilike.${term},content.ilike.${term}`);
query = query.or(`title.ilike.${term},content.ilike.${term},category.ilike.${term}`);


if (params.search) {
const term = `%${params.search}%`;
query = query.or(`title.ilike.${term},content.ilike.${term}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The client-side filtering in app/admin/notifications/page.tsx also searches within the category field. To make server-side searching consistent and to enable moving all filtering logic to the server, you should also include the category field in this OR condition. The category column is nullable, but ilike on a null value will evaluate to false in a WHERE clause, which is the desired behavior here.

Suggested change
query = query.or(`title.ilike.${term},content.ilike.${term}`);
query = query.or(`title.ilike.${term},content.ilike.${term},category.ilike.${term}`);

@pixelsama pixelsama merged commit 47cdde6 into ifLabX:feat/notification Nov 23, 2025
1 of 3 checks passed
@pixelsama pixelsama deleted the feat/notification-updates branch November 23, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ui UI components, layouts, styling, accessibility. size:XXL This PR changes 1000+ lines, ignoring generated files. type:feature Request for a brand-new capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant