-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow user to enter query input fields (#1227)
* feat: allow user to enter message inputs * chore: ui changes * refactor * chore: review changes
- Loading branch information
1 parent
7ac76d6
commit 730542f
Showing
8 changed files
with
502 additions
and
81 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
68 changes: 68 additions & 0 deletions
68
frontend/src/app/(routes)/cosmwasm/components/MessageInputFields.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,68 @@ | ||
import { TxStatus } from '@/types/enums'; | ||
import { CircularProgress } from '@mui/material'; | ||
import Image from 'next/image'; | ||
import React from 'react'; | ||
|
||
const MessageInputFields = ({ | ||
fields, | ||
handleChange, | ||
onQuery, | ||
expandField, | ||
queryLoading, | ||
}: { | ||
fields: MessageInputField[]; | ||
handleChange: (e: React.ChangeEvent<HTMLInputElement>, index: number) => void; | ||
onQuery: (index: number) => void; | ||
expandField: (index: number) => void; | ||
queryLoading: TxStatus; | ||
}) => { | ||
return ( | ||
<div className="w-full flex flex-col gap-4"> | ||
{fields.map((field, index) => ( | ||
<div | ||
key={field.name} | ||
className="bg-[#ffffff14] rounded-2xl p-6 space-y-6" | ||
> | ||
<div className="flex justify-between items-center"> | ||
<div className="text-[14px]">{field.name}</div> | ||
<Image | ||
onClick={() => expandField(index)} | ||
className="cursor-pointer" | ||
src={'/expand-icon.svg'} | ||
height={24} | ||
width={24} | ||
alt="Expand" | ||
/> | ||
</div> | ||
{field?.open ? ( | ||
<div className="space-y-6"> | ||
<div className="message-input-wrapper"> | ||
<input | ||
className="message-input-field" | ||
type="text" | ||
placeholder={`Enter ${field.name}`} | ||
value={field.value} | ||
onChange={(e) => handleChange(e, index)} | ||
autoFocus={true} | ||
/> | ||
</div> | ||
<button | ||
type="button" | ||
onClick={() => onQuery(index)} | ||
className="primary-gradient text-[12px] font-medium py-[6px] px-6 leading-[20px] rounded-lg h-10 w-20 flex-center-center" | ||
> | ||
{queryLoading === TxStatus.PENDING ? ( | ||
<CircularProgress size={18} sx={{ color: 'white' }} /> | ||
) : ( | ||
'Query' | ||
)} | ||
</button> | ||
</div> | ||
) : null} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default MessageInputFields; |
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.