import { CrossCircle } from "../Components/Icons/CrossCircle"; import { EmbeddableControl } from "../types"; import { Link } from "react-router-dom"; import { UserStake } from "../Components/UserWidget"; import { useActions, useAppState } from "../overmind"; import { useState } from "react"; import Modal from "antd/lib/modal/Modal"; export const JoinDaoWidget = ({ embedded, setNext }: React.PropsWithChildren) => { const state = useAppState(); const actions = useActions(); const DAO_DOMAIN = state.config.settings.newcoin.daoDomain; const justStaked = [...state.api.cache.stakeHistory].reverse().find((h) => h.user.username === DAO_DOMAIN); const isStaking = state.indicators.specific["api.user.stake"]; const APP_USER = { username: DAO_DOMAIN }; const [visible, setVisible] = useState(true); // const [staking, setStaking] = useState(false); const currentStake = (state.newcoin.pools || {})["CGY"]; const isMember = currentStake >= 1087; const done = ( { stakeDelta, stakeValue, preStakeValue }: { stakeDelta: number; stakeValue: number; preStakeValue: number } = { stakeDelta: 0, stakeValue: 0, preStakeValue: 0, }, ) => { if ( isMember && ((!preStakeValue && stakeDelta && state.flows.user.create.justCreated) || !state.flows.user.create.justCreated) && /^\/?$/.test(state.routing.location) // !justStaked && // !isStaking ) { actions.routing.historyPush({ location: "/explore" }); return <>; } }; done(); if (!state.newcoin.pools || !state.api.auth.user?.id) return <>; if (!state.api.auth.authorized) // || state.indicators.isWorking return <>; const minValue = isMember ? 100 : 1087; return ( : <>} onCancel={() => { if (!isMember) return; setVisible(false); actions.routing.historyPush({ location: "/explore" }); }} > {/* {JSON.stringify(useAppState().newcoin.pools["CGY"])} */} {isMember ? ( <>

You are a member of the Newlife DAO

You may increase your stake or visit the {DAO_DOMAIN} home page.
) : ( <>

Join the Newlife DAO

Newlife is governed by the community. To join the app, you need to own at least 1000 $LIFE on your account.

1087

$GNCO

By clicking "Stake" you will deposit 1087 $GNCO into the DAO to receive 1000 $LIFE tokens. You can recover them anytime minus the stake 10% fee.

{/* */} {/* actions.api.user.stake({ user: APP_USER, amount: "1087.0000" })}> {staking ? <>In progress : <>Join the DAO} */}
)} setStaking(false)} buttonText={!isMember ? "Join the DAO" : "Stake more"} />

Learn more about app staking

); }; export const JoinDao = JoinDaoWidget;