import { ModalStatus } from '@/types';
import { useState } from 'react';

function useTextsBasedOnActivityState(setStatus: React.Dispatch<React.SetStateAction<ModalStatus>>){
    const signInTexts = {
        title: "Welcome Back!",
        subTitle: "We missed you! Please sign in.",
        buttonText: "Sign In",
        netlifyFunction: "triggerSignInEmail"
    }
    
    const [textOnUse, setTextOnUse] = useState(signInTexts)
    
    const whenModalOpens = () => {
        const signInModal = document.getElementById("sign-in-modal");
        if (!signInModal) return;
        const nameAttribute = signInModal.getAttribute("name");
        switch(nameAttribute){
            case "signIn":
                setTextOnUse(signInTexts);
                break;
            default:
                setTextOnUse(signInTexts);
                break;
        }
        setTimeout(() => setStatus(ModalStatus.Default), 500);
    }

    return {textOnUse, whenModalOpens}
}

export default useTextsBasedOnActivityState;