Skip to content

購入報告をuserIdで登録するようフロントエンドを更新#1061

Merged
Chikuwa0141 merged 18 commits intodevelopfrom
feat/Chikuwa/buy-report-paid-by-user-id-frontend
Mar 22, 2026
Merged

購入報告をuserIdで登録するようフロントエンドを更新#1061
Chikuwa0141 merged 18 commits intodevelopfrom
feat/Chikuwa/buy-report-paid-by-user-id-frontend

Conversation

@Chikuwa0141
Copy link
Copy Markdown
Collaborator

@Chikuwa0141 Chikuwa0141 commented Mar 6, 2026

対応Issue

https://nut-m-e-g.slack.com/archives/C020WQ3GY07/p1766662579010449

概要

  • 購入報告の立替者を、手入力文字列中心から paidByUserId 中心に変更しました
  • 購入報告の「立替者」欄は手入力を廃止し、表示専用(readOnly)に変更しました。見た目も編集画面と同じ薄いグレーにしています

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

image image

テスト項目

  • 購入報告が正常に行われること
  • 購入報告一覧より、立替者名が表示されること
  • 購入報告一覧より、購入報告の編集が行えること

備考

  • テストの際は、http://localhost:3000/yearperiodsにアクセスして2026を作成、予算管理ページで新たに部門、物品を作成、userへの部門割り当てを行わないとMy Pageから購入報告できないと思います

2026/03/19追記

  • 複数のuserIdからusernameを取得するAPIを追加
image

2026/03/21追記

  • ↑をやめて、getuserのAPIを修正し指定したidのuser情報を取得できるように
image
  • 購入報告一覧だけじゃなく、MyPageも変えなきゃだけどそれは別で今度やることとする

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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!

このプルリクエストは、購入報告システムにおける立替者の管理を強化し、ユーザーエクスペリエンスを向上させることを目的としています。具体的には、立替者をユーザーIDで追跡するように変更し、新規報告作成時にはログインユーザーを自動的に設定し、このフィールドを読み取り専用にすることで、データの正確性を高めています。また、購入報告一覧画面での表示もこの新しいユーザーIDベースのロジックに対応しています。

Highlights

  • 購入報告の立替者管理の改善: 購入報告における立替者の管理方法を、手入力の文字列からユーザーIDを基盤とする方式に更新しました。これにより、データの整合性が向上し、ユーザーエクスペリエンスが改善されます。
  • フロントエンドの入力フォーム変更: 購入報告の作成・編集画面において、「立替者」フィールドが読み取り専用となり、ログイン中のユーザー名が自動的に設定されるようになりました。これにより、手入力の手間が省かれ、入力ミスが減少します。
  • APIモデルの更新: BuyReport、BuyReportDetail、BuyReportWithDivisionIdの各APIモデルにpaidByUserIdフィールドが追加され、立替者をユーザーIDで管理できるようになりました。
  • 購入報告一覧での立替者表示の改善: 購入報告一覧画面で、立替者名がpaidByUserIdに基づいて表示されるようになり、より正確な情報が提供されます。paidByUserIdがない場合は既存のpaidByがフォールバックとして表示されます。
  • コードフォーマットの統一: 多数のファイルでclassName属性の記述方法が統一され、コードの可読性と保守性が向上しました。
Changelog
  • view/next-project/src/components/auth/SignInView.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/auth/SignUpView.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/budget_managements/AddBudgetManagementModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/budget_managements/BudgetManagement.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/budget_managements/DeleteBudgetManagementModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/budget_managements/EditBudgetManagementModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/Dropdown.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/Header/Header.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/Loading/Loading.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/PulldownButton.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/Radio/Radio.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/RegistModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/Select/Select.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/SideNav.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/Tooltip/Tooltip.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/common/UserDropdown.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/create_purchase_report/FileUploadField.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/create_purchase_report/usePurchaseReportForm.ts
    • useGetDivisionsIdをインポートしました。
    • purchaseReportの初期状態にpaidByUserIdを追加し、paidByuserNameで初期化しました。
    • 編集モード時にdivisionDataを取得するロジックを追加しました。
    • 新規作成時にログインユーザーを立替者として自動設定するuseEffectフックを追加しました。
    • submitBuyReport関数にpaidByUserIdを含めるように更新しました。
  • view/next-project/src/components/fund_information/FundInformationHeader.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/layout/LoginLayout.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/layout/MainLayout/MainLayout.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/mypage/TableSection.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/DetailEditModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/DetailPage1.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/DetailPage2.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/EditModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/PurchaseOrderListModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/PurchaseReportAddModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/PurchaseReportConfirmModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/ReceiptModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/purchasereports/UploadFileModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/AddBlankInvoiceModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/AddBlankReceiptModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/AddPdfDetailModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/DetailPage1.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/DetailPage2.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/FilterModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/PaymentDayModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/SponsorActivitiesAddModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsoractivities/UploadFileModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/sponsors/SponsorEditModal.tsx
    • 不要な空行を削除しました。
  • view/next-project/src/components/teacher/AddModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/teacher/EditModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/components/users/DeleteModal.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/generated/model/buyReport.ts
    • paidByフィールドをオプショナルに変更し、paidByUserIdフィールドを追加しました。
  • view/next-project/src/generated/model/buyReportDetail.ts
    • paidByUserIdフィールドを追加しました。
  • view/next-project/src/generated/model/buyReportWithDivisionId.ts
    • paidByUserIdフィールドを追加しました。
  • view/next-project/src/pages/404.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/500.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/_app.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/create_purchase_report/index.tsx
    • setPurchaseReportの分割代入を削除しました。
    • isFormValidのチェックからpaidByの検証を削除しました。
    • 「立替者」フィールドを読み取り専用にし、paidByUserIdに基づいて表示するように更新しました。
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/fund_informations/[id]/edit.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/fund_informations/create/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/purchase_report_list/index.tsx
    • @api/api_methodsからgetを、@type/commonからUser型をインポートしました。
    • ユーザー名マップを管理するための状態を追加しました。
    • すべてのユーザーを取得してユーザー名マップを作成するロジックを追加しました。
    • 「立替者」列の表示をpaidByUserIduserNameMapに基づいて更新しました。
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/reset_password/[id]/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/reset_password/request/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/sponsoractivities/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/sponsors/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/sponsorstyles/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/teachers/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/users/index.tsx
    • className属性のフォーマットを修正しました。
  • view/next-project/src/pages/yearperiods/index.tsx
    • className属性のフォーマットを修正しました。
Activity
  • プルリクエストが作成されました。
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.

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

cloudflare-workers-and-pages Bot commented Mar 6, 2026

Deploying finansu with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3130cc3
Status: ✅  Deploy successful!
Preview URL: https://5a06b87d.finansu.pages.dev
Branch Preview URL: https://feat-chikuwa-buy-report-paid-b6ba.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

このプルリクエストでは、購入報告の立替者をuserIdで管理するようにフロントエンドが更新されていますね。全体的に、ロジックの変更は適切で、特にusePurchaseReportFormフックのリファクタリングはコードの堅牢性を高める良い改善だと感じました。
いくつか、コードの可読性と保守性をさらに向上させるための提案をコメントしましたので、確認してみてください。

@Chikuwa0141 Chikuwa0141 requested a review from hikahana March 8, 2026 15:40
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.

コメントした!

setPurchaseReport((prev) => ({
...prev,
paidBy: userName,
paidByUserId: userId || undefined,
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]
undefinedを許容しているけど、undefinedになることってあるんだっけ?
paidByUserIdって必須になってるんじゃないんだっけ?

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.

その認識であってます!
paidByだけで登録することとか考えちゃってたかも。
今後はpaidByUserId必須で登録するから修正する

Comment on lines +63 to +92
useEffect(() => {
let isMounted = true;

const fetchUsers = async () => {
try {
const usersResponse = await get(`${process.env.CSR_API_URI}/users`);
const users = Array.isArray(usersResponse)
? usersResponse
: Array.isArray(usersResponse?.data)
? usersResponse.data
: [];

if (!isMounted) return;

const nameMap = Object.fromEntries(
(users as User[]).map((targetUser) => [targetUser.id, targetUser.name]),
);
setUserNameMap(nameMap);
} catch (error) {
console.error('Failed to fetch users:', error);
}
};

fetchUsers();

return () => {
isMounted = 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.

これisMounted機能してないと思う~

Suggested change
useEffect(() => {
let isMounted = true;
const fetchUsers = async () => {
try {
const usersResponse = await get(`${process.env.CSR_API_URI}/users`);
const users = Array.isArray(usersResponse)
? usersResponse
: Array.isArray(usersResponse?.data)
? usersResponse.data
: [];
if (!isMounted) return;
const nameMap = Object.fromEntries(
(users as User[]).map((targetUser) => [targetUser.id, targetUser.name]),
);
setUserNameMap(nameMap);
} catch (error) {
console.error('Failed to fetch users:', error);
}
};
fetchUsers();
return () => {
isMounted = false;
};
}, []);
useEffect(() => {
const fetchUsers = async () => {
try {
const usersResponse = await get(`${process.env.CSR_API_URI}/users`);
const users = Array.isArray(usersResponse)
? usersResponse
: Array.isArray(usersResponse?.data)
? usersResponse.data
: [];
const nameMap = Object.fromEntries(
(users as User[]).map((targetUser) => [targetUser.id, targetUser.name]),
);
setUserNameMap(nameMap);
} catch (error) {
console.error('Failed to fetch users:', error);
}
};
fetchUsers();
}, []);

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.

あ、違うわ。
これそもそもいらなくない?
buyReports にデータ保存されてると思うけどこのマウント処理ってなんで追加したの?

おそらくだけど、useCurrentUserにuserIdとuserNameが保存されているはずだからこのidをbuyReportsに入れてあげるでいいかも!

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.

isMounted消します!
buyReportsに保存してるpaidByは購入報告時の名前(過去のデータと合わせるために残ってるだけ)で、今後はPaidByUserIdで管理していくからuserIdからユーザー名を引いてる。
useCurrentUserはログインしてるユーザーのデータだけだからここでは使わないと思う!

Chikuwa0141 and others added 9 commits March 14, 2026 14:14
…eport-paid-by-user-id-frontend

# Conflicts:
#	view/next-project/src/components/budget_managements/BudgetManagement.tsx
#	view/next-project/src/components/budget_managements/DeleteBudgetManagementModal.tsx
#	view/next-project/src/components/common/Header/Header.tsx
#	view/next-project/src/components/common/RegistModal.tsx
#	view/next-project/src/components/common/SideNav.tsx
#	view/next-project/src/components/layout/LoginLayout.tsx
#	view/next-project/src/components/layout/MainLayout/MainLayout.tsx
#	view/next-project/src/components/purchasereports/EditModal.tsx
#	view/next-project/src/components/purchasereports/PurchaseOrderListModal.tsx
#	view/next-project/src/components/purchasereports/PurchaseReportConfirmModal.tsx
#	view/next-project/src/components/purchasereports/ReceiptModal.tsx
#	view/next-project/src/components/purchasereports/UploadFileModal.tsx
#	view/next-project/src/components/sponsoractivities/AddBlankInvoiceModal.tsx
#	view/next-project/src/components/sponsoractivities/AddBlankReceiptModal.tsx
#	view/next-project/src/components/sponsoractivities/FilterModal.tsx
#	view/next-project/src/components/sponsoractivities/SponsorActivitiesAddModal.tsx
#	view/next-project/src/components/sponsoractivities/UploadFileModal.tsx
#	view/next-project/src/generated/hooks.ts
#	view/next-project/src/pages/404.tsx
#	view/next-project/src/pages/500.tsx
#	view/next-project/src/pages/create_purchase_report/index.tsx
#	view/next-project/src/pages/reset_password/[id]/index.tsx
#	view/next-project/src/pages/sponsoractivities/index.tsx
#	view/next-project/src/pages/sponsorstyles/index.tsx
#	view/next-project/src/pages/users/index.tsx
#	view/next-project/src/pages/yearperiods/index.tsx
Comment thread api/internals/domain/user.go Outdated
Comment thread api/externals/handler/user_handler.go Outdated
Comment thread api/internals/usecase/user_usecase.go Outdated
Comment thread api/externals/handler/user_handler.go Outdated
Comment thread api/externals/repository/user_repository.go Outdated
Comment thread openapi/openapi.yaml Outdated
Comment thread api/externals/repository/user_repository.go Outdated
Comment thread api/externals/repository/user_repository.go Outdated
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.

一つだけ質問載せてるけど動いてるならよさげ〜

ds := dialect.
From("users").
Select("users.*").
Where(goqu.I("users.id").In(ids))
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.

order by descのは口頭でいらないってなった感じ?

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.

何も話してない!
けどソートする必要現時点でないなと思ったからやめた!

@Chikuwa0141 Chikuwa0141 merged commit 96a4577 into develop Mar 22, 2026
1 check passed
@Chikuwa0141 Chikuwa0141 deleted the feat/Chikuwa/buy-report-paid-by-user-id-frontend branch March 22, 2026 02:03
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