Skip to content

学内募金ページの実装(ガワだけ)#1086

Merged
hikahana merged 22 commits intodevelopfrom
feat/Chikuwa/add-fund-page
Apr 30, 2026
Merged

学内募金ページの実装(ガワだけ)#1086
hikahana merged 22 commits intodevelopfrom
feat/Chikuwa/add-fund-page

Conversation

@Chikuwa0141
Copy link
Copy Markdown
Collaborator

概要

  • 学内募金ページ /campus_fund を追加
  • 棟ごとの募金額カードを表示
  • スマホ画面向けにカードサイズ・余白・モーダル幅を調整
  • 居室一覧モーダルを追加
  • 募金登録モーダルを追加
  • Prettierを更新
  • Prettier 3に合わせて設定を調整
  • useState の型定義が保存時に崩れる問題に対応
    • Prettierが原因だと思ったら書き方の問題でした
  • DBスキーマ変更により /teachers がエラーになるため、教員一覧リンクを一時的に無効化

画面スクリーンショット等

image image image

テスト項目

  • PC、スマホどちらの画面でも正常に画面が表示、遷移すること

備考

  • ※node_modulesの更新が必要です

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 27, 2026

Deploying finansu with  Cloudflare Pages  Cloudflare Pages

Latest commit: a5a4479
Status: ✅  Deploy successful!
Preview URL: https://e54a8c26.finansu.pages.dev
Branch Preview URL: https://feat-chikuwa-add-fund-page.finansu.pages.dev

View logs

Copy link
Copy Markdown
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 implements the 'Campus Fund' feature, adding components for donation reporting and teacher selection, a new dashboard page, and the react-datepicker dependency. It also updates project configurations, including a Prettier upgrade and VS Code settings. Feedback focuses on removing a debug console.log, correcting invalid Tailwind CSS classes, improving type safety by using generics and avoiding unsafe type casting, and optimizing performance by memoizing floor option calculations.

Comment thread view/next-project/src/components/campus_fund/ReportModal.tsx Outdated
Comment thread view/next-project/src/components/campus_fund/SelectTeacherModal.tsx Outdated
Comment on lines +12 to +14
const [selectedBuilding, setSelectedBuilding] = useState(
null as CampusFundBuildingSummary | null,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

useState の型定義にはジェネリクスを使用するのが一般的です。17行目の selectedTeacher も同様に修正を検討してください。

Suggested change
const [selectedBuilding, setSelectedBuilding] = useState(
null as CampusFundBuildingSummary | null,
);
const [selectedBuilding, setSelectedBuilding] = useState<CampusFundBuildingSummary | null>(
null,
);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

意図的にこの書き方をしている。
useState<T | null>(null) が保存時の自動整形で useState(null) に崩れるため、回避として null as T | null を使っています。selectedTeacher も同様。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

そもそもnull許容されるんだっけ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

募金ページを開いた直後は建物・教員が未選択だからnull許容してる。
あと自動整形で変になっちゃう問題治ってたから提案通りに修正

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

なるほど!

// TODO APIのレスポンスを修正してyearIdをちゃんと取得できるようにする
type YearData = { id: number; year: number; createdAt: string; updatedAt: string };

const years = yearData.data as unknown as YearData[];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

as unknown as による型キャストは避け、スキーマ定義を更新して正しい型を取得できるようにすることを優先してください(組織の一般ルール参照)。

References
  1. APIの型が不一致な場合、型キャストではなくスキーマの更新を優先する。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

年度取得API修正時に治す。
TODOとしている

},
];

const floorOptions = [...new Set(teachers.map((teacher) => teacher.floorNumber))];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

floorOptions の計算がレンダリングのたびに行われています。teachers 配列をコンポーネントの外に移動し、floorOptions も定数として定義するか useMemo で最適化することを検討してください。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

API繋ぎこみ前のモックデータのためこのままとする

Copy link
Copy Markdown
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

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

先にちゃんとスキーマ作ってから一緒に開発すればよかったなー
繋ぎ込みの時にスキーマ周りの修正必要かも。
コードだけチラ見でレビューです

if (!teacher || !formData.receivedAt || !formData.price || !user?.id || !yearId) return;

try {
setErrorMessage('');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[imo]
これ初期化って感じ?
それなら、useStateの宣言時に空を入れてるから不要かも。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

エラー→再度登録の際にエラーメッセージが出たままになってしまうため、登録処理開始時に初期化するようにしている

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

あああああああああああああああああああああ
その動きがあったか

setErrorMessage('');
setIsSubmitting(true);

const payload: CreateCampusDonationPayload = {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

prettier怒られてるね。
payload特に使ってないし、CreateCampusDonationPayloadだけの呼び出しでもいいのかも?
await CreateCampusDonationPayload
みたいな感じってエラー起きるっけ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ESLint止めてて見落とし
PayLoad削除
API繋ぎこみのときいいかんじにする

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

おけまる

});
handleClose();
alert('募金の登録が完了しました!');
} catch (error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ここもprettierだね。error使ってないし、なくてもいいんでない?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ESLint止めてて見落とし
error使っていないため削除


<div className='flex items-center gap-3'>
<label className='w-20 shrink-0 text-right text-xs font-bold text-gray-600 md:text-sm'>
記入担当者
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[ask]
ここって名前だったけ?user_idが入るようになったとかじゃなかったけ?
認識違ってたらごめんね

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

表示用にuser.nameを出してるけど、登録時にAPIに送るのはuserid

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

あねあね

className='w-full border-b border-gray-400 bg-gray-100 text-sm focus:outline-none md:text-base'
/>
</div>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ここ一行消しといてーー
インデントである程度わかると思うから下にある改行も消していいかも

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

対応しました!

const ReportModal = ({ isOpen, onClose, building, teacher, yearId, onBack }: Props) => {
const initialFormData: CampusFundFormData = {
receivedAt: new Date(),
price: '',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[ask]
priceって数値じゃなくて文字列なのはなんでだろう?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

文字列として仮のデータを作っていたことが原因
他のページ参考に数値に修正

}

const OpenEditModalButton = (props: Props) => {
const [showModal, setShowModal] = useState(false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

showModal使ってないね〜
使わない想定なら↓でいいよーー
const [_, setShowModal] = useState(false)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ESLint止めてて見落としてた
このファイル使ってないのに残っていたので削除しました

>
戻る
</button>
<PrimaryButton onClick={handleSubmit} disabled={isSubmitDisabled || isSubmitting}>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[ask]
isSubmitDisabledってisSubmittingと同じことしてる感じがしているんだけど分けた理由とかある?
もし同じならisSubmittingだけでもいいかなーって

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

入力データの不足により送信ボタンを押せない(isSubmitDisabled)と送信中だから送信ボタンを押せない(isSubmitting)で分けてる
あと登録ボタンを「登録する」から「登録中」の表示に変えたり

// フォーム入力中のstate用
export interface CampusFundFormData {
receivedAt: Date | null;
price: string;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

これnumberでいいかも?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

numberに修正

Comment on lines +12 to +14
const [selectedBuilding, setSelectedBuilding] = useState(
null as CampusFundBuildingSummary | null,
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

そもそもnull許容されるんだっけ?

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

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

LGTM

@hikahana hikahana merged commit cab0f9f into develop Apr 30, 2026
4 checks passed
@hikahana hikahana deleted the feat/Chikuwa/add-fund-page branch April 30, 2026 02:09
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.

3 participants