-
Notifications
You must be signed in to change notification settings - Fork 0
numbersにuniqueを付与 #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
numbersにuniqueを付与 #330
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a unique constraint to the number field in the numbers schema and implements error handling for duplicate number submissions in the admin interface.
- Adds database unique constraint on
numbers.numberfield to prevent duplicate entries - Implements client-side error handling with user-friendly alerts for duplicate number submissions
- Updates ESLint configuration with improved import ordering and TypeScript rules
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| api/migrations/default/1720521696814_auto/up.sql | Adds unique constraint to numbers.number field |
| view-admin/src/pages/index.tsx | Implements error handling for duplicate submissions and improves import organization |
| view-admin/package.json | Updates ESLint dependencies and configuration |
| view-admin/.eslintrc.json | Adds comprehensive ESLint rules for import ordering and TypeScript |
| .vscode/settings.json | Configures VS Code for automatic linting and formatting |
view-admin/src/pages/index.tsx
Outdated
| ) | ||
| ) { | ||
| // TODO: ちゃんとしたコンポーネントで実装する | ||
| alert(`${submitNumber} は既に入力済みです。`); |
Copilot
AI
Aug 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the native alert() function is not recommended for user notifications in modern web applications. Consider using a proper toast notification or modal component for better user experience and accessibility.
view-admin/src/pages/index.tsx
Outdated
| // TODO: ちゃんとしたコンポーネントで実装する | ||
| alert(`${submitNumber} は既に入力済みです。`); | ||
| } else { | ||
| alert("エラーが発生しました。"); |
Copilot
AI
Aug 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the native alert() function is not recommended for user notifications in modern web applications. Consider using a proper toast notification or modal component for better user experience and accessibility.
| onError: (err) => { | ||
| if ( | ||
| err.graphQLErrors.some( | ||
| (e) => e.extensions?.code === "constraint-violation", |
Copilot
AI
Aug 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error code 'constraint-violation' is a magic string that should be extracted to a constant for better maintainability and to avoid typos.
パッと見たところ,package.json更新して,動作できたら良さそうだと思います. |
YosukeIida
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
対応Issue
概要
adminのみの変更です。
numbers schemaのnumberにunique制約を付与しました。
フロント側でエラーハンドリングを追加
import周りのeslintを追加。邪魔だから消しました。
実装詳細
submitの際にonErrorでunique制約エラーの際、アラートで入力済みと返すように修正。
それ以外のエラーはエラーが発生しましたとだけ返しています。
画面スクリーンショット等
テスト項目
備考