@@ -11,6 +11,7 @@ import {
1111} from "@/components/ui/select" ;
1212import type { Member } from "@/types/member" ;
1313import type { Payment } from "@/types/payment" ;
14+ import { DialogMemo } from "./DialogMemo" ;
1415import { Button } from "./ui/button" ;
1516
1617interface BillingDetailCardProps {
@@ -27,8 +28,8 @@ export default function BillingDetailCard({
2728 setPayments,
2829} : BillingDetailCardProps ) {
2930 const [ details , setDetails ] = useState <
30- Array < { id : number ; paidFor : number ; amount : number | "" } >
31- > ( [ { id : - 1 , paidFor : - 1 , amount : "" } ] ) ;
31+ Array < { id : number ; paidFor : number ; amount : number | "" ; memo : string } >
32+ > ( [ { id : - 1 , paidFor : - 1 , amount : "" , memo : "" } ] ) ;
3233 const { eventId } = useParams ( ) ;
3334
3435 // payerに関連するpaymentsをdetailsに反映
@@ -40,8 +41,9 @@ export default function BillingDetailCard({
4041 id : p . id ,
4142 paidFor : p . paidFor ,
4243 amount : p . amount ,
44+ memo : p . memo ,
4345 } ) ) ,
44- { id : - 1 , paidFor : - 1 , amount : "" as number | "" } ,
46+ { id : - 1 , paidFor : - 1 , amount : "" as number | "" , memo : "" } ,
4547 ] ;
4648
4749 setDetails ( newDetails ) ;
@@ -66,6 +68,7 @@ export default function BillingDetailCard({
6668 paidBy : paidBy . id ,
6769 paidFor : newValue ,
6870 amount : "" ,
71+ memo : "" ,
6972 } ;
7073 setPayments ( ( prev ) => [ ...prev , newPayment ] ) ;
7174
@@ -103,7 +106,7 @@ export default function BillingDetailCard({
103106
104107 const last = updated [ updated . length - 1 ] ;
105108 if ( last . amount !== "" && last . paidFor !== - 1 ) {
106- updated . push ( { id : - 1 , paidFor : - 1 , amount : "" } ) ;
109+ updated . push ( { id : - 1 , paidFor : - 1 , amount : "" , memo : "" } ) ;
107110 }
108111
109112 return updated ;
@@ -137,7 +140,10 @@ export default function BillingDetailCard({
137140 index === details . length - 1 &&
138141 ( detail . paidFor !== - 1 || detail . amount !== "" )
139142 ) {
140- setDetails ( ( prev ) => [ ...prev , { id : - 1 , paidFor : - 1 , amount : "" } ] ) ;
143+ setDetails ( ( prev ) => [
144+ ...prev ,
145+ { id : - 1 , paidFor : - 1 , amount : "" , memo : "" } ,
146+ ] ) ;
141147 }
142148 } ;
143149
@@ -210,6 +216,13 @@ export default function BillingDetailCard({
210216 onBlur = { ( ) => handleBlur ( index ) }
211217 />
212218 < span > 円もらう</ span >
219+ < DialogMemo
220+ index = { index }
221+ disabled = { ! isSelectable }
222+ details = { details }
223+ setDetails = { setDetails }
224+ setPayments = { setPayments }
225+ />
213226 < Button
214227 variant = "destructive"
215228 onClick = { ( ) => handleDeleteBilling ( index ) }
0 commit comments