11import BN from "bn.js" ;
22import React , { useState } from "react" ;
33import { FiArrowDownLeft } from "react-icons/fi" ;
4+ import { Popover } from "@headlessui/react" ;
45
56import { useSunriseStake } from "../common/context/sunriseStakeContext" ;
6- import { useModal } from "../common/hooks" ;
77import { ZERO } from "../common/utils" ;
8- import { AmountInput , Button , Panel , Spinner } from "../common/components" ;
9- import { LockWarningModal } from "../common/components/modals/LockWarningModal" ;
8+ import { AmountInput , Panel } from "../common/components" ;
109
1110interface LockFormProps {
1211 lock : ( amount : string ) => Promise < any > ;
1312}
14- const LockForm : React . FC < LockFormProps > = ( { lock } ) => {
13+ const LockForm : React . FC < LockFormProps > = ( ) => {
1514 const { details } = useSunriseStake ( ) ;
1615 const [ amount , setAmount ] = useState ( "" ) ;
17- const [ valid , setValid ] = useState ( false ) ;
18- const [ isBusy , setIsBusy ] = useState ( false ) ;
19- const lockModal = useModal ( ( ) => {
20- setIsBusy ( true ) ;
21- lock ( amount ) . finally ( ( ) => {
22- setIsBusy ( false ) ;
23- } ) ;
24- } ) ;
16+ const [ , setValid ] = useState ( false ) ;
2517
2618 return (
2719 < Panel className = "flex flex-row mx-auto mb-9 p-3 sm:p-4 rounded-lg w-full sm:w-[80%] md:w-[60%] lg:w-[40%] max-w-xl" >
28- < LockWarningModal
29- ok = { lockModal . onModalOK }
30- cancel = { lockModal . onModalClose }
31- show = { lockModal . modalShown }
32- />
3320 < AmountInput
3421 className = "mr-4 basis-3/4"
3522 token = "gSOL"
@@ -40,15 +27,15 @@ const LockForm: React.FC<LockFormProps> = ({ lock }) => {
4027 mode = "LOCK"
4128 variant = "small"
4229 />
43- < Button
44- onClick = { lockModal . trigger }
45- disabled = { ! valid || isBusy }
46- className = "mr-auto sm:mr-0 m-auto"
47- size = "sm"
48- >
49- { isBusy ? < Spinner size = "1rem" className = "mr-1" /> : null }
50- Lock < FiArrowDownLeft className = "inline" size = { 24 } / >
51- </ Button >
30+ < Popover className = "relative mr-auto sm:mr-0 m-auto" >
31+ < Popover . Button className = "inline-flex items-center border-2 rounded-lg leading-6 shadow-sm border-green bg-green text-white px-4 py-2 text-base opacity-50" >
32+ Lock < FiArrowDownLeft className = "inline ml-1" size = { 24 } />
33+ </ Popover . Button >
34+ < Popover . Panel className = "absolute z-[100] bottom-full right-0 mb-2 bg-danger text-white text-sm rounded-lg p-4 w-64 shadow-xl" >
35+ Locking is disabled. Sunrise is shutting down - please withdraw your
36+ SOL.
37+ </ Popover . Panel >
38+ </ Popover >
5239 </ Panel >
5340 ) ;
5441} ;
0 commit comments