forked from hashgraph/hedera-smart-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dapp-feat: QueryTokenPermission feature complete (hashgraph#318) (has…
…hgraph#377) Signed-off-by: Logan Nguyen <[email protected]> Signed-off-by: Mo Shaikjee <[email protected]>
- Loading branch information
1 parent
c915eb5
commit 7e42031
Showing
6 changed files
with
498 additions
and
16 deletions.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
...nd/src/components/contract-interaction/hts/shared/components/TokenPermissionInfoModal.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,129 @@ | ||
/*- | ||
* | ||
* Hedera Smart Contracts | ||
* | ||
* Copyright (C) 2023 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import { Dispatch, SetStateAction } from 'react'; | ||
import { convertCalmelCaseFunctionName } from '@/utils/common/helpers'; | ||
import { | ||
Tr, | ||
Th, | ||
Td, | ||
Modal, | ||
Table, | ||
Tbody, | ||
ModalBody, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalOverlay, | ||
ModalContent, | ||
TableContainer, | ||
ModalCloseButton, | ||
} from '@chakra-ui/react'; | ||
|
||
interface PageProps { | ||
APIMethods: 'ALLOWANCE' | 'GET_APPROVED' | 'IS_APPROVAL'; | ||
tokenInfo: any; | ||
eventMaps: any; | ||
isOpen: boolean; | ||
onClose: () => void; | ||
initialParamValues?: any; | ||
setTokenInfo?: Dispatch<any>; | ||
setParamValues?: Dispatch<any>; | ||
setIsSuccessful?: Dispatch<SetStateAction<boolean>>; | ||
} | ||
|
||
const TokenPermissionInfoModal = ({ | ||
APIMethods, | ||
tokenInfo, | ||
isOpen, | ||
onClose, | ||
setTokenInfo, | ||
eventMaps, | ||
setParamValues, | ||
setIsSuccessful, | ||
initialParamValues, | ||
}: PageProps) => { | ||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
onClose={() => { | ||
onClose(); | ||
if (setTokenInfo) setTokenInfo({}); | ||
if (setIsSuccessful) setIsSuccessful(false); | ||
if (setParamValues) setParamValues(initialParamValues); | ||
}} | ||
isCentered | ||
size={'3xl'} | ||
> | ||
<ModalOverlay /> | ||
<ModalContent | ||
className="h-fit flex flex-col gap-3 rounded-xl drop-shadow-xl | ||
bg-secondary text-white font-styrene w-[30rem]" | ||
> | ||
{/* title */} | ||
<ModalHeader>Token Information</ModalHeader> | ||
<ModalCloseButton /> | ||
|
||
{/* break line */} | ||
<hr className="border-t border-white/40 -mt-3" /> | ||
|
||
{/* body */} | ||
<ModalBody> | ||
<TableContainer className="overflow-x-hidden"> | ||
<Table variant="simple" size={'sm'}> | ||
<Tbody> | ||
<Tr> | ||
<Th color={'#82ACF9'}>{convertCalmelCaseFunctionName(eventMaps[APIMethods])}</Th> | ||
{APIMethods === 'GET_APPROVED' && ( | ||
<Td className="flex justify-end"> | ||
{`${tokenInfo.slice(0, 6)}...${tokenInfo.slice(-6)}`} | ||
</Td> | ||
)} | ||
{APIMethods === 'IS_APPROVAL' && ( | ||
<Td className="flex justify-end"> | ||
{JSON.stringify(tokenInfo === 1).toUpperCase()} | ||
</Td> | ||
)} | ||
{APIMethods === 'ALLOWANCE' && <Td className="flex justify-end">{tokenInfo}</Td>} | ||
</Tr> | ||
</Tbody> | ||
</Table> | ||
</TableContainer> | ||
</ModalBody> | ||
|
||
{/* footer */} | ||
<ModalFooter className="flex flex-col gap-3"> | ||
<button | ||
onClick={() => { | ||
onClose(); | ||
if (setTokenInfo) setTokenInfo({}); | ||
if (setIsSuccessful) setIsSuccessful(false); | ||
if (setParamValues) setParamValues(initialParamValues); | ||
}} | ||
className="border border-button-stroke-violet px-6 py-2 rounded-lg font-medium hover:bg-button-stroke-violet hover:text-white transition duration-300" | ||
> | ||
Acknowledge | ||
</button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default TokenPermissionInfoModal; |
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
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.