-
Notifications
You must be signed in to change notification settings - Fork 1
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
請求書の編集機能の追加 #869
Merged
Merged
請求書の編集機能の追加 #869
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
This file contains 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 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 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
144 changes: 144 additions & 0 deletions
144
view/next-project/src/components/sponsoractivities/EditInvoiceModal.tsx
This file contains 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,144 @@ | ||
import clsx from 'clsx'; | ||
import React, { useState } from 'react'; | ||
import { PrimaryButton, OutlinePrimaryButton, CloseButton, Modal, Input } from '@components/common'; | ||
import { Invoice, InvoiceSponsorStyle } from '@type/common'; | ||
|
||
interface ModalProps { | ||
invoice: Invoice; | ||
setInvoice: (invoce: Invoice) => void; | ||
setIsOpen: (isOpen: boolean) => void; | ||
} | ||
|
||
export default function EditInvoiceModal(props: ModalProps) { | ||
const { invoice, setInvoice, setIsOpen } = props; | ||
const [editInvoice, setEditInvoice] = useState<Invoice>(invoice); | ||
|
||
const handler = | ||
(input: string) => | ||
( | ||
e: | ||
| React.ChangeEvent<HTMLSelectElement> | ||
| React.ChangeEvent<HTMLInputElement> | ||
| React.ChangeEvent<HTMLTextAreaElement>, | ||
) => { | ||
setEditInvoice({ ...editInvoice, [input]: e.target.value }); | ||
}; | ||
|
||
const onChangeSponsorStyle = (inputInvoiceSponsorStyle: InvoiceSponsorStyle, index: number) => { | ||
const newInvoiceSponsorStyles = editInvoice.invoiceSponsorStyle.map( | ||
(invoiceSponsorStyle, i) => { | ||
if (i === index) { | ||
return inputInvoiceSponsorStyle; | ||
} else { | ||
return invoiceSponsorStyle; | ||
} | ||
}, | ||
); | ||
const totalPrice = newInvoiceSponsorStyles.reduce( | ||
(price: number, invoiceSponsorStyle: InvoiceSponsorStyle): number => { | ||
return price + invoiceSponsorStyle.price; | ||
}, | ||
0, | ||
); | ||
setEditInvoice({ | ||
...editInvoice, | ||
invoiceSponsorStyle: newInvoiceSponsorStyles, | ||
totalPrice: totalPrice, | ||
}); | ||
}; | ||
|
||
const handleRegister = () => { | ||
setInvoice(editInvoice); | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<Modal className='md:w-1/2'> | ||
<div className='w-full'> | ||
<div className='ml-auto w-fit'> | ||
<CloseButton | ||
onClick={() => { | ||
setIsOpen(false); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
<div className='mx-auto mb-10 w-fit text-xl text-black-600'>請求書の修正</div> | ||
<div className=''> | ||
<div className='my-4 grid grid-cols-5 items-center justify-items-center gap-2'> | ||
<p className='text-black-600'>企業名</p> | ||
<div className='col-span-4 w-full'> | ||
<Input value={editInvoice.sponsorName} onChange={handler('sponsorName')}></Input> | ||
</div> | ||
<p className='text-black-600'>企業担当者名</p> | ||
<div className='col-span-4 w-full'> | ||
<Input value={editInvoice.managerName} onChange={handler('managerName')}></Input> | ||
</div> | ||
<p className='text-black-600'>実行委員担当者名</p> | ||
<div className='col-span-4 w-full'> | ||
<Input value={editInvoice.fesStuffName} onChange={handler('fesStuffName')}></Input> | ||
</div> | ||
</div> | ||
<div className='max-h-48 overflow-y-auto'> | ||
<table className='mb-4 w-full table-fixed border-collapse'> | ||
<thead> | ||
<tr className='border border-x-white-0 border-b-primary-1 border-t-white-0 py-3'> | ||
<th className='w-3/4 px-6 pb-2'> | ||
<div className='text-center text-sm text-black-600'>協賛内容(オプション)</div> | ||
</th> | ||
<th className='w-1/4 px-6 pb-2'> | ||
<div className='text-center text-sm text-black-600'>値段</div> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{editInvoice.invoiceSponsorStyle && | ||
editInvoice.invoiceSponsorStyle.map((invoiceSponsorStyle, index) => ( | ||
<tr | ||
key={index} | ||
className={clsx('border border-x-white-0 border-t-white-0', { | ||
'border-b-primary-1': index === editInvoice.invoiceSponsorStyle.length - 1, | ||
})} | ||
> | ||
<td className='py-3'> | ||
<Input | ||
value={invoiceSponsorStyle.styleName} | ||
className='' | ||
onChange={(e) => { | ||
onChangeSponsorStyle( | ||
{ ...invoiceSponsorStyle, styleName: e.target.value }, | ||
index, | ||
); | ||
}} | ||
></Input> | ||
</td> | ||
<td className='py-3'> | ||
<Input | ||
value={invoiceSponsorStyle.price} | ||
onChange={(e) => { | ||
onChangeSponsorStyle( | ||
{ ...invoiceSponsorStyle, price: Number(e.target.value) }, | ||
index, | ||
); | ||
}} | ||
></Input> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
<div className='flex flex-row justify-center gap-5'> | ||
<OutlinePrimaryButton | ||
onClick={() => { | ||
setIsOpen(false); | ||
}} | ||
> | ||
戻る | ||
</OutlinePrimaryButton> | ||
<PrimaryButton onClick={handleRegister}>編集完了</PrimaryButton> | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
} |
30 changes: 30 additions & 0 deletions
30
view/next-project/src/components/sponsoractivities/OpenEditInvoiceModalButton.tsx
This file contains 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,30 @@ | ||
import * as React from 'react'; | ||
import { useState } from 'react'; | ||
|
||
import { EditButton } from '../common'; | ||
import EditInvoiceModal from './EditInvoiceModal'; | ||
import { Invoice } from '@/type/common'; | ||
|
||
interface Props { | ||
children?: React.ReactNode; | ||
invoice: Invoice; | ||
setInvoice: (invoice: Invoice) => void; | ||
} | ||
|
||
const OpenEditInvoiceModalButton: React.FC<Props> = (props) => { | ||
const { invoice, setInvoice } = props; | ||
const [isOpen, setIsOpen] = useState(false); | ||
const onOpen = () => { | ||
setIsOpen(true); | ||
}; | ||
return ( | ||
<> | ||
<EditButton onClick={onOpen} size='M' /> | ||
{isOpen && ( | ||
<EditInvoiceModal setInvoice={setInvoice} invoice={invoice} setIsOpen={setIsOpen} /> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default OpenEditInvoiceModalButton; |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
値段に誤って全角文字を入力すると、NaN表示になり修正が不可能になる問題があります。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます。
修正しました。
全角の対応