From b2d11a351a0651b63ea740ffba000ba35a6765a7 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 24 Sep 2025 01:08:08 -0400 Subject: [PATCH] signup source working --- frontend/apps/editor3d/.env.bkup | 11 - frontend/apps/editor3d/app/signup.html | 16 -- frontend/apps/editor3d/app/src/signup.tsx | 200 ------------------ frontend/apps/editor3d/build-ci.sh | 69 ------ frontend/apps/editor3d/run.sh | 2 - .../apps/editor3d/script/netlify_build.sh | 31 --- .../login-modal/src/lib/login-modal.tsx | 4 + 7 files changed, 4 insertions(+), 329 deletions(-) delete mode 100644 frontend/apps/editor3d/.env.bkup delete mode 100644 frontend/apps/editor3d/app/signup.html delete mode 100644 frontend/apps/editor3d/app/src/signup.tsx delete mode 100755 frontend/apps/editor3d/build-ci.sh delete mode 100755 frontend/apps/editor3d/script/netlify_build.sh diff --git a/frontend/apps/editor3d/.env.bkup b/frontend/apps/editor3d/.env.bkup deleted file mode 100644 index f3a612888e..0000000000 --- a/frontend/apps/editor3d/.env.bkup +++ /dev/null @@ -1,11 +0,0 @@ -BASE_API="https://api.storyteller.ai" -GOOGLE_API="https://storage.googleapis.com" -FUNNEL_API="https://style.storyteller.ai" -CDN_API="https://cdn.storyteller.ai" -GRAVATAR_API="https://www.gravatar.com" -DEPLOY_PRIME_URL="https://studio-staging.studio.storyteller.ai" -REACT_APP_PUBLIC_POSTHOG_KEY="phc_jBFgac0mVALAFk3negnSfYCcHgvkT00yBLQDmCDYNBb" -REACT_APP_PUBLIC_POSTHOG_UI="https://us.i.posthog.com" -DEPLOY_CONTEXT="DEVELOPMENT" -CONTEXT="DEVELOPMENT" -UPLOAD_API_VIDEO="https://upload.storyteller.ai" diff --git a/frontend/apps/editor3d/app/signup.html b/frontend/apps/editor3d/app/signup.html deleted file mode 100644 index d07286061c..0000000000 --- a/frontend/apps/editor3d/app/signup.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Signup | ArtCraft 3D - - - - - - - -
- - - diff --git a/frontend/apps/editor3d/app/src/signup.tsx b/frontend/apps/editor3d/app/src/signup.tsx deleted file mode 100644 index 50ded5420f..0000000000 --- a/frontend/apps/editor3d/app/src/signup.tsx +++ /dev/null @@ -1,200 +0,0 @@ -import { faEnvelope, faKey, faUser } from "@fortawesome/pro-solid-svg-icons"; -import { GlobalSettingsManager } from "./pages/PageEnigma/GlobalSettingsManager"; -import { Input } from "@storyteller/ui-input"; -import { Button } from "@storyteller/ui-button"; -import { addToast, authentication, signUp } from "~/signals"; -import { FormEvent, useRef, useState, StrictMode } from "react"; -import { AUTH_STATUS, ToastTypes } from "~/enums"; -import { useSignalEffect, useSignals } from "@preact/signals-react/runtime"; -import { useNavigate, useSearchParams, BrowserRouter } from "react-router-dom"; -import { createRoot } from "react-dom/client"; - -import "./styles/normalize.css"; -import "./styles/tailwind.css"; -import "./styles/base.css"; -import "@fortawesome/fontawesome-svg-core/styles.css"; - -import { config } from "@fortawesome/fontawesome-svg-core"; - -config.autoAddCss = false; /* eslint-disable import/first */ - -const regEx = - /^(([^<>()[\].,;:\s@"]+(.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i; - -// TODO(bt,2025-04-19): Make these configurable -const ENV = { - GOOGLE_API: "https://studio.storyteller.ai", - FUNNEL_API: "https://studio.storyteller.ai", - CDN_API: "https://cdn-2.fakeyou.com", - GRAVATAR_API: "https://studio.storyteller.ai", - DEPLOY_PRIME_URL: "https://studio.storyteller.ai", -}; - -const SIGNUP_SOURCE = "artcraft"; - -export default function SignUpScreen() { - useSignals(); - const navigate = useNavigate(); - const formRef = useRef(null); - const [usernameError, setUsernameError] = useState(""); - const [emailError, setEmailError] = useState(""); - const [passwordError, setPasswordError] = useState(""); - const [passwordConfirmationError, setPasswordConfirmationError] = - useState(""); - const [searchParams] = useSearchParams(); - const { status: authStatus } = authentication; - - const handleOnSubmit = (ev: FormEvent) => { - ev.preventDefault(); - if (formRef.current) { - const form = new FormData(formRef.current); - const email = form.get("email")?.toString(); - const password = form.get("password")?.toString(); - const passwordConfirmation = form - .get("password-confirmation") - ?.toString(); - const username = form.get("username")?.toString(); - setUsernameError(""); - if (!username || username.length < 6) { - setUsernameError("Username must be at least 6 characters long"); - } - setEmailError(""); - if (!email || !email.match(regEx)) { - setEmailError("Email must be a valid email address"); - } - setPasswordError(""); - if (!password || password.length < 8) { - setPasswordError("Password must be at least 8 characters long"); - } - setPasswordConfirmationError(""); - if (!passwordError && passwordConfirmation !== password) { - setPasswordConfirmationError("Passwords do not match"); - } - - if ( - !usernameError && - !passwordError && - !emailError && - !passwordConfirmationError && - signUp - ) { - signUp({ - username: username!, - email: email!, - password: password!, - passwordConfirmation: passwordConfirmation!, - signupSource: SIGNUP_SOURCE, - }).then((error) => { - console.log("Error occured", error); - if (error) { - addToast(ToastTypes.ERROR, error); - } - }); - } - } - }; // end handleOnSubmit - - useSignalEffect(() => { - const redirectPath = searchParams.get("redirect"); - if (authStatus.value === AUTH_STATUS.LOGGED_IN) { - navigate(redirectPath ? redirectPath : "/"); - return; - } - if (authStatus.value === AUTH_STATUS.NO_ACCESS) { - window.open("https://storyteller.ai/", "_self"); - return; - } - }); - - return ( -
-
- ArtCraft Logo -
-
-
-

Sign up

-
- - - - - -
-
-
- -
-

Already have an account?

- - Log in - -
-
-
-
- ); -} - -// TODO: Replace environment variables from `root.tsx` -createRoot(document.getElementById("root")!).render( - <> - - - - - - - , -); diff --git a/frontend/apps/editor3d/build-ci.sh b/frontend/apps/editor3d/build-ci.sh deleted file mode 100755 index 3b6f201bfc..0000000000 --- a/frontend/apps/editor3d/build-ci.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# NB: This file is executed by Netlify to build the website - -# Verbose printing, exit on failure. -set -euxo pipefail - -# Echo env vars -env - -# Add the GIT SHA to the build -# This must be done before everything else, or it will get cached with the build. -# (This might be making the builds less performant?) -# COMMIT_REF is defined by Netlify to be the commit SHA -# We want a short 8 character reference. -echo "Labelling build with short SHA..." -SHORT_SHA=$(echo "${COMMIT_REF}" | cut -c1-8) - -echo "Baking current git SHA to code"; - -find . -type f -exec sed -i "s/%CURRENT_STORYTELLER_GIT_VERSION%/${SHORT_SHA}/g" {} + - -#### -# Expressions hack -#### - -echo "Baking expressions feature flag ENV to code"; - -echo "Value of EXPRESSIONS env var is: ${EXPRESSIONS}" - -if [ "$EXPRESSIONS" = "TRUE" ] || [ "$EXPRESSIONS" = "true" ] ; then - expressions_value="true" -else - expressions_value="false" -fi - -echo "Value of expressions is: ${expressions_value}" - -find . -type f -exec sed -i "s/%EXPRESSIONS_VALUE%/${expressions_value}/g" {} + - -echo "Baking URL/API ENV configs to code"; - -# NB: We can't use slashes as the sed escape character: -# https://stackoverflow.com/a/27787551 -d=$'\03' -find . -type f -exec sed -i "s${d}%BUILD_BASE_API%${d}${BASE_API}${d}g" {} + -find . -type f -exec sed -i "s${d}%BUILD_GOOGLE_API%${d}${GOOGLE_API}${d}g" {} + -find . -type f -exec sed -i "s${d}%BUILD_FUNNEL_API%${d}${FUNNEL_API}${d}g" {} + -find . -type f -exec sed -i "s${d}%BUILD_CDN_API%${d}${CDN_API}${d}g" {} + -find . -type f -exec sed -i "s${d}%BUILD_UPLOAD_VIDEO%${d}${UPLOAD_VIDEO_API}${d}g" {} + -find . -type f -exec sed -i "s${d}%BUILD_MEDIA_VIDEO%${d}${MEDIA_VIDEO_API}${d}g" {} + -find . -type f -exec sed -i "s${d}%BUILD_GRAVATAR_VIDEO%${d}${GRAVATAR_API}${d}g" {} + -find . -type f -exec sed -i "s${d}%DEPLOY_PRIME_URL%${d}${DEPLOY_PRIME_URL}${d}g" {} + -find . -type f -exec sed -i "s${d}%DEPLOY_CONTEXT%${d}${DEPLOY_CONTEXT}${d}g" {} + -find . -type f -exec sed -i "s${d}%CONTEXT%${d}${CONTEXT}${d}g" {} + -find . -type f -exec sed -i "s${d}%UPLOAD_API_VIDEO%${d}${UPLOAD_API_VIDEO}${d}g" {} + - -# Replace Posthog env variables in the code -find . -type f -exec sed -i "s${d}%REACT_APP_PUBLIC_POSTHOG_KEY%${d}${REACT_APP_PUBLIC_POSTHOG_KEY}${d}g" {} + -find . -type f -exec sed -i "s${d}%REACT_APP_PUBLIC_POSTHOG_UI%${d}${REACT_APP_PUBLIC_POSTHOG_UI}${d}g" {} + - -# TODO: Run tests when we add them. - -# Ensure the environment variables are exported -export REACT_APP_PUBLIC_POSTHOG_KEY -export REACT_APP_PUBLIC_POSTHOG_UI -export CONTEXT -# Run build.x -npm run build - diff --git a/frontend/apps/editor3d/run.sh b/frontend/apps/editor3d/run.sh index 893905a236..6aeb23f0e1 100755 --- a/frontend/apps/editor3d/run.sh +++ b/frontend/apps/editor3d/run.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -#!/usr/bin/env bash - set -euxo pipefail # Kill any process running on port 5741, which will block startup diff --git a/frontend/apps/editor3d/script/netlify_build.sh b/frontend/apps/editor3d/script/netlify_build.sh deleted file mode 100755 index 52929304e7..0000000000 --- a/frontend/apps/editor3d/script/netlify_build.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -# Add the GIT SHA to the build -# This must be done before everything else, or it will get cached with the build. -# (This might be making the builds less performant?) -# COMMIT_REF is defined by Netlify to be the commit SHA -# We want a short 8 character reference. -echo "Labelling build with short SHA..." -SHORT_SHA=$(echo "${COMMIT_REF}" | cut -c1-8) - -echo "Baking current git SHA to code"; -find . -type f -exec sed -i "s/%CURRENT_STORYTELLER_GIT_VERSION%/${SHORT_SHA}/g" {} + - -echo "Install packages" -npm install - -echo "Build Editor 3D" -nx build editor3d --verbose - -echo "Change to project dir" -pushd apps/editor3d/ - -echo "Copy files to putput directory" -cp _headers dist/ -#cp _redirects dist/ -#cp "404.html" dist/ - -echo "List final files in build" -find dist/ diff --git a/frontend/libs/components/login-modal/src/lib/login-modal.tsx b/frontend/libs/components/login-modal/src/lib/login-modal.tsx index 95cb79fcb2..a200b5426c 100644 --- a/frontend/libs/components/login-modal/src/lib/login-modal.tsx +++ b/frontend/libs/components/login-modal/src/lib/login-modal.tsx @@ -11,6 +11,9 @@ import { import { ArtCraftSignUp } from "./artcraft-signup"; import { UsersApi } from "@storyteller/api"; import { useLoginModalStore } from "./useLoginModalStore"; + +const SIGNUP_SOURCE_ARTCRAFT = "artcraft"; + interface LoginModalProps { onClose?: () => void; videoSrc2D?: string; @@ -249,6 +252,7 @@ export function LoginModal({ email, password, passwordConfirmation, + signupSource: SIGNUP_SOURCE_ARTCRAFT, }); console.log(signupResponse);