学内募金API繋ぎこみ#1091
Conversation
There was a problem hiding this comment.
Code Review
This pull request transitions the campus donation feature from mock data to a full API integration. It updates the database schema with a unique index, modifies the repository to fetch individual donation records, and enhances the OpenAPI specification with building group keys and donation IDs. The frontend components are refactored to use generated hooks for data synchronization and now support both creating and updating donations. Reviewers identified a potential maintenance risk regarding hardcoded building groups in the use case and advised against using type casts to resolve schema-related type mismatches in the frontend.
| {ID: 1, Name: "機械・建設棟", GroupKey: generated.MechanicalCivilEngineering}, | ||
| {ID: 2, Name: "電気棟", GroupKey: generated.ElectricalEngineering}, | ||
| {ID: 3, Name: "生物棟", GroupKey: generated.Biology}, | ||
| {ID: 4, Name: "環境・システム棟", GroupKey: generated.EnvironmentalSystem}, | ||
| {ID: 5, Name: "物質・材料経営情報棟", GroupKey: generated.MaterialsManagementInformation}, | ||
| {ID: 6, Name: "総合研究棟", GroupKey: generated.GeneralResearch}, | ||
| {ID: 7, Name: "原子力・システム安全棟", GroupKey: generated.NuclearSystemSafety}, | ||
| {ID: 8, Name: "事務局棟", GroupKey: generated.Administration}, | ||
| {ID: 9, Name: "極限エネルギ密度工学研究センター", GroupKey: generated.ExtremeEnergyDensityResearchCenter}, | ||
| {ID: 10, Name: "工作センター", GroupKey: generated.MachineShop}, | ||
| {ID: 11, Name: "大型実験棟", GroupKey: generated.LargeExperiment}, | ||
| {ID: 12, Name: "分析計測センター", GroupKey: generated.AnalysisInstrumentationCenter}, | ||
| {ID: 999, Name: "その他", GroupKey: generated.Other}, |
| type YearData = { id: number; year: number; createdAt: string; updatedAt: string }; | ||
|
|
||
| const years = yearData.data as unknown as YearData[]; | ||
| const years = yearData.data as unknown as Year[]; |
There was a problem hiding this comment.
yearData.data を Year[] にキャストしていますが、これは OpenAPI スキーマ(year_periods)に id が定義されていないために発生している型不整合を回避するための実装と思われます。共通ルールに従い、キャストによる解決ではなく、スキーマを更新して id を含めるように修正することを優先してください。
References
- スキーマから生成されたAPI型が実際のAPIレスポンスと一致しない場合は、スキーマを更新して正しいデータ構造を反映させることを優先し、型キャスト(例:as unknown as CorrectType)を恒久的な修正として使用しないでください。
対応Issue
学内募金の実装
概要
学内募金画面で仮データを使用していた箇所をAPI連携に変更しました。
画面スクリーンショット等
テスト項目
備考