-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/walt/purchase report sort frontend #1044
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
Open
nakatashingo
wants to merge
30
commits into
develop
Choose a base branch
from
feat/walt/purchase-report-sort-frontend
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
eda29a3
[add] Add buy reports summary endpoint and related types
nakatashingo 3fa14ff
[add] Implement PurchaseReportSummaryAmounts component and integrate …
nakatashingo 9d47aeb
[otr] Simplify JSX formatting in PurchaseReportSummaryAmounts component
nakatashingo 44167c1
[add] PurchaseReportPaidByFilterModal component and integrate it into…
nakatashingo 3b6ec0a
[fix] Update button text in PurchaseReportPaidByFilterModal
nakatashingo 3c61495
[fix] Update button text in PurchaseReportPaidByFilterModal to improv…
nakatashingo dff5edd
[add] Implement PurchaseReportSummaryAmounts component and integrate …
nakatashingo 72f01f1
[otr] Simplify JSX formatting in PurchaseReportSummaryAmounts component
nakatashingo 95d6546
[add] PurchaseReportPaidByFilterModal component and integrate it into…
nakatashingo 2c7c7b7
[fix] Update button text in PurchaseReportPaidByFilterModal
nakatashingo 2894b01
[fix] Update button text in PurchaseReportPaidByFilterModal to improv…
nakatashingo d88ee44
[add] Add "絞り込みなし" option to bureau selection in PurchaseReportPaidBy…
nakatashingo 96fdbdb
refactor: Reorganize imports and clean up whitespace in PurchaseRepor…
nakatashingo 29d8823
formatted by workflow
nakatashingo ffe2764
[add] Insert additional payment receipt entries in initial schema seed
nakatashingo 1b78882
[fix] Improve styling and structure in PurchaseReportPaidByFilterModa…
nakatashingo b7cda1c
[fix] Simplify user filtering logic and improve type checking in Purc…
nakatashingo 9dbe13b
[fix] Update PurchaseReportPaidByFilterModal to use paidBy instead of…
nakatashingo 566c3a9
[fix] Enhance PurchaseReportPaidByFilterModal and PurchaseReports to …
nakatashingo bf65e4f
[add] Implement search functionality and dropdown for paidBy selectio…
nakatashingo 11ed226
[fix] Refactor filtering logic in PurchaseReports for improved readab…
nakatashingo d632646
[add] Create styles for name selection in PurchaseReportPaidByFilterM…
nakatashingo a160d56
[fix] Correct CSS background formatting and re-import styles in Purch…
nakatashingo 38d8d19
[refactor] Remove CSS styles and integrate react-select for name sele…
nakatashingo db78d6f
[refactor] Clean up formatting and improve readability in PurchaseRep…
nakatashingo 0101f1f
Merge branch 'develop' into feat/walt/purchase-report-sort-frontend
nakatashingo 906cf6a
[refactor] Replace userAtom with useCurrentUser hook in PurchaseRepor…
nakatashingo b8d26b8
[fix] Ensure buy report data is updated after status change in Purcha…
nakatashingo 1c1db0a
[refactor] Improve formatting and readability in PurchaseReportPaidBy…
nakatashingo d8d2705
[refactor] Add userNameMap to map user IDs to names in PurchaseReport…
nakatashingo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
view/next-project/src/components/purchasereports/PurchaseReportPaidByFilterModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import React, { FC, useEffect, useMemo, useState } from 'react'; | ||
|
|
||
| import { CloseButton, Modal, OutlinePrimaryButton, Select } from '@components/common'; | ||
| import { Bureau, User } from '@type/common'; | ||
|
|
||
| interface PurchaseReportPaidByFilterModalProps { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| onApply: (selection: { | ||
| bureauId: number | null; | ||
| paidByUserId: number | null | undefined; | ||
| }) => void; | ||
| bureaus: Bureau[]; | ||
| users: User[]; | ||
| selectedBureauId: number | null; | ||
| selectedPaidByUserId: number | null | undefined; | ||
| } | ||
|
|
||
| const PurchaseReportPaidByFilterModal: FC<PurchaseReportPaidByFilterModalProps> = (props) => { | ||
| const { isOpen, onClose, onApply, bureaus, users, selectedBureauId, selectedPaidByUserId } = | ||
| props; | ||
|
|
||
| const [draftBureauId, setDraftBureauId] = useState<number | null>(selectedBureauId); | ||
| const [draftPaidByUserId, setDraftPaidByUserId] = useState<number | null | undefined>( | ||
| selectedPaidByUserId, | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| if (!isOpen) return; | ||
| setDraftBureauId(selectedBureauId); | ||
| setDraftPaidByUserId(selectedPaidByUserId); | ||
| }, [isOpen, selectedBureauId, selectedPaidByUserId]); | ||
|
|
||
| const bureauNameMap = useMemo( | ||
| () => | ||
| new Map( | ||
| bureaus.map((bureau) => [bureau.id ?? 0, bureau.name] as const).filter(([id]) => id > 0), | ||
| ), | ||
| [bureaus], | ||
| ); | ||
|
|
||
| const filteredUsers = useMemo(() => { | ||
| if (!draftBureauId) return users; | ||
| return users.filter((user) => user.bureauID === draftBureauId); | ||
| }, [draftBureauId, users]); | ||
|
|
||
| const paidBySelectValue = draftPaidByUserId === null ? 'none' : draftPaidByUserId ?? ''; | ||
|
|
||
| const handleBureauChange = (event: React.ChangeEvent<HTMLSelectElement>) => { | ||
| const value = event.target.value; | ||
| const nextBureauId = value === '' ? null : Number(value); | ||
| setDraftBureauId(nextBureauId); | ||
| setDraftPaidByUserId(undefined); | ||
| }; | ||
|
|
||
| const handlePaidByChange = (event: React.ChangeEvent<HTMLSelectElement>) => { | ||
| const value = event.target.value; | ||
| if (value === '') { | ||
| setDraftPaidByUserId(undefined); | ||
| return; | ||
| } | ||
| if (value === 'none') { | ||
| setDraftPaidByUserId(null); | ||
| return; | ||
| } | ||
| setDraftPaidByUserId(Number(value)); | ||
| }; | ||
|
|
||
| const handleApply = () => { | ||
| onApply({ | ||
| bureauId: draftBureauId ?? null, | ||
| paidByUserId: draftPaidByUserId, | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal className='w-[90vw] max-w-[440px] p-6 shadow-lg' onClick={onClose}> | ||
| <div className='flex justify-end'> | ||
| <CloseButton onClick={onClose} /> | ||
| </div> | ||
| <div className='mt-2 space-y-5'> | ||
| <div> | ||
| <p className='mb-2 text-sm text-black-600'>局名</p> | ||
| <Select value={draftBureauId ?? ''} onChange={handleBureauChange}> | ||
| <option value=''>絞り込みなし</option> | ||
| {bureaus.map((bureau) => ( | ||
| <option key={bureau.id ?? 0} value={bureau.id ?? 0}> | ||
| {bureau.name} | ||
| </option> | ||
| ))} | ||
| </Select> | ||
| </div> | ||
| <div> | ||
| <p className='mb-2 text-sm text-black-600'>氏名</p> | ||
| <Select value={paidBySelectValue} onChange={handlePaidByChange}> | ||
| <option value='none'>絞り込みなし</option> | ||
| {filteredUsers.map((user) => { | ||
| const bureauName = bureauNameMap.get(user.bureauID); | ||
| const label = draftBureauId || !bureauName ? user.name : `${bureauName} ${user.name}`; | ||
| return ( | ||
| <option key={user.id} value={user.id}> | ||
| {label} | ||
| </option> | ||
| ); | ||
| })} | ||
| </Select> | ||
| {/* NOTE: paid_by_user_id の NULL を絞り込む仕様が未定義のため「立替者なし」は未実装。 */} | ||
| </div> | ||
| </div> | ||
| <div className='mt-6 flex justify-center'> | ||
| <OutlinePrimaryButton onClick={handleApply}>絞り込む</OutlinePrimaryButton> | ||
| </div> | ||
| </Modal> | ||
| ); | ||
| }; | ||
|
|
||
| export default PurchaseReportPaidByFilterModal; | ||
26 changes: 26 additions & 0 deletions
26
view/next-project/src/components/purchasereports/PurchaseReportSummaryAmounts.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import React from 'react'; | ||
|
|
||
| interface PurchaseReportSummaryAmountsProps { | ||
| unsettledAmountText: string; | ||
| unpackedAmountText: string; | ||
| className?: string; | ||
| } | ||
|
|
||
| export default function PurchaseReportSummaryAmounts({ | ||
| unsettledAmountText, | ||
| unpackedAmountText, | ||
| className = 'text-sm text-black-600 md:ml-auto', | ||
| }: PurchaseReportSummaryAmountsProps) { | ||
| return ( | ||
| <div className={className}> | ||
| <div className='inline-grid grid-cols-[auto_auto_auto] gap-1'> | ||
| <span className='whitespace-nowrap'>未清算金額</span> | ||
| <span className='whitespace-nowrap'>:</span> | ||
| <span className='min-w-[12ch] whitespace-nowrap text-right'>{unsettledAmountText} 円</span> | ||
| <span className='whitespace-nowrap'>未封詰め金額</span> | ||
| <span className='whitespace-nowrap'>:</span> | ||
| <span className='min-w-[12ch] whitespace-nowrap text-right'>{unpackedAmountText} 円</span> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.