"use client"; import { Link } from "@nextui-org/link"; import { Dispatch, SetStateAction, useEffect, useState } from "react"; import { Address, formatEther } from "viem"; import { useAccount } from "wagmi"; import PersonaFlow from "./PersonaFlow"; type Participant = { id: string; projectId: number; address: Address; volume: bigint; volumeUSD: bigint; balance: bigint; stakedBalance: bigint; paymentsCount: number; }; const formatCurrency = (value: bigint): string => { const dec = parseFloat(formatEther(value)); return dec.toLocaleString("en-US", { style: "decimal", minimumFractionDigits: 2, maximumFractionDigits: 2, }); }; export default function SignedInActions({ kycState, setKYCState, referrer, }: { kycState?: "failed" | "completed" | "not-found" | "not-started"; setKYCState: Dispatch< SetStateAction< "completed" | "failed" | "not-found" | "not-started" | undefined > >; referrer?: string | null; }) { const { address } = useAccount(); const [participant, setParticipant] = useState(); useEffect(() => { if (!address) return; (async () => { const res = await ( await fetch(`/api/jb?address=${address.toLowerCase()}`) ).json(); if (res.data.participant) { setParticipant({ id: res.data.participant.id, projectId: res.data.participant.projectId, address: res.data.participant.address, balance: BigInt(res.data.participant.balance), volume: BigInt(res.data.participant.volume), volumeUSD: BigInt(res.data.participant.volumeUSD), paymentsCount: res.data.participant.paymentsCount, stakedBalance: BigInt(res.data.participant.stakedBalance), }); } else { setParticipant(null); } })(); }, [address]); useEffect(() => { if (!address) return; (async () => { const fetchRes = await fetch( `/api/status?address=${address.toLowerCase()}` ); if (fetchRes.status === 404) { setKYCState("not-found"); return; } const res = await fetchRes.json(); if (res.status === "N") { setKYCState("not-started"); } else { setKYCState(res.status); } })(); }, [address]); let voucherAmount = participant ? formatCurrency(participant.balance) : undefined; // if (!participant) { // return ( //
//

the connected wallet has not purchased any vouchers.

// //
// ); // } return ( <>

Purchased Vouchers

{voucherAmount ? (

You have purchased {voucherAmount} Vouchers{" "} at{" "} juicebox.money/@welshare . Note: These are not the WEL tokens. The WEL tokens will be distributed to users who were accepted to purchase.

) : (

You have not purchased any vouchers.

)}
{voucherAmount && (

{voucherAmount} vouchers

)}
{kycState === "completed" && ( <>

Application State: You're in!

Congratulations! Your application was successful. You will receive WEL tokens in a 1:1 ratio of your vouchers (20% at TGE, 1-month cliff, then 6-month linear vesting).

)} {kycState === "not-started" && ( <>

Application State: Please complete the KYC process!

Attention: You still need to complete the KYC process to apply for the WEL token purchase. If you don't complete this step,{" "} you won't receive the WEL token. You will need your ID and will be required to take a selfie.

)} {kycState === "not-found" && ( <>

Application State: Not Found

You have not purchased any vouchers or we couldn't find your KYC application. Please check whether you have used the currently connected wallet ({address}) to purchase vouchers. If you think this is an error,{" "} please contact us on Telegram

)} {kycState === "failed" && ( <>

Application State: Rejected

Unfortunately, your application{" "} was not successful. If you have purchased vouchers you are eligible for a refund. The team will announce refund instructions soon.

)}
{kycState === "not-started" && (
{" "} { console.log("PERSONA", { inquiryId, status, fields }); setKYCState(status as "completed" | "failed"); }} />
)}

Follow us on Twitter and join our Telegram to stay updated.

Twitter:{" "} https://x.com/welsharehealth

Telegram:{" "} https://t.me/welsharehealth

{/* {kycState === "failed" && (

You unfortunately did not pass the KYC process. If you provided an email address, we'll get back to you.

)} */} ); }