import { useAppSelector } from "@/hooks"; import confetti from "canvas-confetti"; import { useEffect } from "react"; // getOutcomeStr: function () { // return { // 0: "UNKNOWN", 1: "ENTER", // 2: "INCOMPLETE", 3: "COMPLETE" // }[this.get('status')] || ''; // } export const Complete = () => { const ts = useAppSelector(state => state.app.taskStatus) return ( <>

Survey Completed

Congratulations! You completed the Survey.

{ts?.user_payout_string}

You may close this tab and return to submit the HIT

) } export const Enter = () => { return ( <>

Entered

You're currently in the Survey

You may close this tab and return to submit the HIT

) } export const InComplete = () => { const ts = useAppSelector(state => state.app.taskStatus) if (!ts) { return null; } return ( <>

HIT Complete

Survey terminated the attempt.

You may close this tab and return to submit the HIT

) } export const Unknown = () => { return ( <>

Task Issue

You're not currently eligible for any Surveys

You may close this tab and return to submit the HIT

) } export const Loading = () => { return (

Loading...

) } const Result = () => { const ts = useAppSelector(state => state.app.taskStatus) const confettiCannons = () => { const end = Date.now() + 3 * 1000 const colors = ["#84cc16", "#1e3a8a", "#ec4899"] const frame = () => { if (Date.now() > end) return confetti({ particleCount: 3, angle: 60, spread: 55, startVelocity: 80, gravity: 0.7, origin: { x: 0, y: 0.8 }, colors: colors, }) confetti({ particleCount: 3, angle: 120, spread: 55, startVelocity: 80, gravity: 0.7, origin: { x: 1, y: 0.8 }, colors: colors, }) requestAnimationFrame(frame) } frame() } useEffect(() => { if (ts?.status === 3) { confettiCannons() } }, [ts]) switch (ts?.status) { case 0: // UNKNOWN return ; case 1: // ENTER return ; case 2: // INCOMPLETE return ; case 3: // COMPLETE return ; default: return ; } }; export default Result;