Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:NUTFes/FinanSu into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
imaimai17468 committed Nov 29, 2023
2 parents 1b65254 + c26c10e commit 73a513c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 12 deletions.
34 changes: 24 additions & 10 deletions view/next-project/src/components/common/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,37 @@ interface Props {
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
children?: React.ReactNode;
type?: string;
datalist?: {
key: string;
data: { id: number; name: string }[];
};
}

function Input(props: Props): JSX.Element {
const className =
'rounded-full border border-primary-1 py-2 px-4' +
(props.className ? ` ${props.className}` : '');
return (
<input
className={clsx(s.input, className)}
placeholder={props.placeholder}
id={props.id}
value={props.value}
onChange={props.onChange}
type={props.type}
>
{props.children}
</input>
<div>
<input
className={clsx(s.input, className)}
placeholder={props.placeholder}
id={props.id}
value={props.value}
onChange={props.onChange}
type={props.type}
list={props.datalist?.key}
>
{props.children}
</input>
{props.datalist && (
<datalist id={props.datalist.key}>
{props.datalist.data.map((option) => (
<option key={option.id} value={option.name} />
))}
</datalist>
)}
</div>
);
}

Expand Down
11 changes: 10 additions & 1 deletion view/next-project/src/components/fund_information/AddModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Modal, CloseButton, Input, Select, PrimaryButton } from '../common';
import { userAtom } from '@/store/atoms';
import { post } from '@api/fundInformations';
import { BUREAUS } from '@constants/bureaus';
import { DONATION_AMOUNT } from '@constants/donationAmount';
import { Department, FundInformation, Teacher, User } from '@type/common';

interface ModalProps {
Expand Down Expand Up @@ -132,7 +133,15 @@ const OpenAddModal: FC<ModalProps> = (props) => {
</div>
<p className='col-span-1 text-black-600'>金額</p>
<div className='col-span-4 w-full'>
<Input className='w-full' value={formData.price} onChange={handler('price')} />
<Input
className='w-full'
value={formData.price}
onChange={handler('price')}
datalist={{
key: 'amoutOptions',
data: DONATION_AMOUNT,
}}
/>
</div>
<p className='col-span-1 text-black-600'>備考</p>
<div className='col-span-4 w-full'>
Expand Down
11 changes: 10 additions & 1 deletion view/next-project/src/components/fund_information/EditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Dispatch, SetStateAction, useEffect, useState, useMemo } from 'react';
import { Modal, Input, Select, CloseButton, PrimaryButton } from '../common';
import { put } from '@api/fundInformations';
import { BUREAUS } from '@constants/bureaus';
import { DONATION_AMOUNT } from '@constants/donationAmount';
import { FundInformation, Teacher, User, Department } from '@type/common';

interface ModalProps {
Expand Down Expand Up @@ -140,7 +141,15 @@ export default function EditModal(props: ModalProps) {
</div>
<p className='col-span-1 text-black-600'>金額</p>
<div className='col-span-4 w-full'>
<Input className='w-full' value={formData.price} onChange={handler('price')} />
<Input
className='w-full'
value={formData.price}
onChange={handler('price')}
datalist={{
key: 'amoutOptions',
data: DONATION_AMOUNT,
}}
/>
</div>
<p className='col-span-1 text-black-600'>備考</p>
<div className='col-span-4 w-full'>
Expand Down
18 changes: 18 additions & 0 deletions view/next-project/src/constants/donationAmount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const DONATION_AMOUNT = [
{
id: 1,
name: '1000',
},
{
id: 2,
name: '2000',
},
{
id: 3,
name: '5000',
},
{
id: 4,
name: '10000',
},
];

0 comments on commit 73a513c

Please sign in to comment.