Skip to content

Conversation

Copy link

Copilot AI commented Aug 18, 2025

This PR fixes a critical issue where events could be created without a valid user group, resulting in inaccessible events with userGroupId=0.

Problem

The event registration form had two issues:

  1. Validation bypass: Empty user group field was converted to 0 by z.coerce.number(), which passed validation but created invalid events that no one could access
  2. Poor UX: No default user group was pre-selected, making it easy for users to accidentally submit with an empty field

Solution

1. Enhanced Validation

Updated the Zod schema in viewmodel.ts to ensure userGroupId is a positive integer:

userGroupId: z.coerce.number({
  required_error: 'ユーザーグループは必須です。',
}).min(1, 'ユーザーグループの指定が不正です。'),

2. Default Value Selection

Modified EventRegisterTemplate.tsx to automatically select the first available user group:

defaultValue: userGroups.length > 0 ? userGroups[0].id.toString() : undefined

Results

  • Empty strings and 0 values now fail validation with proper error message: "ユーザーグループの指定が不正です。"
  • First available user group is automatically pre-selected in the dropdown
  • Prevents creation of inaccessible events with userGroupId=0
  • Improves user experience with sensible defaults

Before and After

The screenshot shows the validation error message being properly displayed when attempting to create an event with an invalid user group.

Fixes #272.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: node /home/REDACTED/work/for-moku/for-moku/front/node_modules/.bin/next build (dns block)
    • Triggering command: next-server (v15.3.2) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Aug 18, 2025

@atomisu0312 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@atomisu0312
Copy link
Contributor

?????

Copilot AI changed the title [WIP] 【イベント】【新規作成】ユーザグループが空でもイベントを作れてしまう(なお誰もアクセスはできない) Fix event creation with empty user group validation and default value Aug 18, 2025
Copilot AI requested a review from atomisu0312 August 18, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【イベント】【新規作成】ユーザグループが空でもイベントを作れてしまう(なお誰もアクセスはできない)

2 participants