Sammy

My Emotional Regulation Journey

Parent Login

const SUPABASE_KEY = "sb_publishable_3rDsv7ZXuOZDihTao51yqg_TBQFGySz"; const supabase = createClient( SUPABASE_URL, SUPABASE_KEY ); window.login = async function() { const email = document.getElementById("email").value; const password = document.getElementById("password").value; document.getElementById("message").textContent = "Logging in..."; const { data, error } = await supabase.auth.signInWithPassword({ email, password }); if (error) { document.getElementById("message").textContent = error.message; return; } const user = data.user; const { data: child, error: childError } = await supabase .from("Children") .select("child_name, program_id") .eq("parent_id", user.id) .single(); if (childError) { document.getElementById("message").textContent = "Database error: " + childError.message + " | Code: " + childError.code; return; } document.getElementById("message").textContent = ""; document.getElementById("childName").textContent = "Welcome! " + child.child_name; document.getElementById("journey").style.display = "block"; }; window.openSammy = async function() { const { data: program, error } = await supabase .from("programmes1") .select("canva_url") .eq("name", "SAMMY 1 - UNDERSTANDING MY FEELINGS") .single(); if (error || !program) { alert("Sammy 1 could not be found."); return; } window.location.href = program.canva_url; };