diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..d58ba26 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,20 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on merge +on: + push: + branches: + - main +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PROMPTGPT_1 }} + channelId: live + projectId: promptgpt-1 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..9fe3c20 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,21 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PROMPTGPT_1 }} + projectId: promptgpt-1 diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 3bfb423..0000000 --- a/public/index.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - Welcome to Firebase Hosting - - - - - - - - - - - - - - - - - - - -
-

Welcome

-

Firebase Hosting Setup Complete

-

You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!

- Open Hosting Documentation -
-

Firebase SDK Loading…

- - - - diff --git a/src/components/Nav/Nav.jsx b/src/components/Nav/Nav.jsx index 80c14f6..d79cd08 100644 --- a/src/components/Nav/Nav.jsx +++ b/src/components/Nav/Nav.jsx @@ -1,7 +1,7 @@ "use client"; import Link from "next/link"; import Image from "next/image"; - +import { AiFillOpenAI } from "react-icons/ai"; @@ -19,6 +19,7 @@ const Nav = () => { alt="PromptGPT Logo" className="object-contain" /> + {/* */}

PromptGPT

diff --git a/src/components/SignUpPage.js b/src/components/SignUpPage.js index 9da7fcf..ab6184d 100644 --- a/src/components/SignUpPage.js +++ b/src/components/SignUpPage.js @@ -1,39 +1,48 @@ -"use client" +"use client"; import Link from "next/link"; import React, { useState } from "react"; import { useFormik } from "formik"; import * as yup from "yup"; -import YupPassword from 'yup-password' +import YupPassword from "yup-password"; import { IoEye } from "react-icons/io5"; import { IoMdEyeOff } from "react-icons/io"; -YupPassword(yup) // extend yup -import {createUserWithEmailAndPassword } from "firebase/auth"; +YupPassword(yup); // extend yup +import { + createUserWithEmailAndPassword, + sendEmailVerification, + updateProfile, +} from "firebase/auth"; import { auth } from "@/utils/firebase"; -import { useToast } from "@/components/ui/use-toast" +import { useToast } from "@/components/ui/use-toast"; import { useRouter } from "next/navigation"; - +import { useAppDispatch } from "@/lib/hooks"; const SignUpPage = () => { - const [showPassword,setShowPassword]=useState("password"); - const [errorMessage,setErrorMessage]=useState(null); - const router=useRouter(); - + const [showPassword, setShowPassword] = useState("password"); + const [errorMessage, setErrorMessage] = useState(null); + const router = useRouter(); + const dispatch = useAppDispatch(); + // const [sentEmail, setSentEmail] = useState(); + const { toast } = useToast(); - const handleShowPassword=()=>{ - if(showPassword==='password'){ - setShowPassword('text'); - } - else{ - setShowPassword('password') - } + const handleShowPassword = () => { + if (showPassword === "password") { + setShowPassword("text"); + } else { + setShowPassword("password"); } + }; const initialValues = { name: "", email: "", password: "", }; const validationSchema = yup.object({ - name: yup.string().min(2, 'Too Short!').max(30, "Must be 30 characters or less").required("Required"), + name: yup + .string() + .min(2, "Too Short!") + .max(30, "Must be 30 characters or less") + .required("Required"), email: yup.string().email("Invalid Email Address").required("Required"), password: yup.string().password().required("Required"), }); @@ -41,23 +50,49 @@ const SignUpPage = () => { const formik = useFormik({ initialValues, validationSchema, - onSubmit: values => { - createUserWithEmailAndPassword(auth, values.email, values.password) - .then((userCredential) => { - // Signed up - const user = userCredential.user; - // console.log(user); - router.push('/') - // ... - }) - .catch((error) => { - const errorCode = error.code; - const errorMessage = error.message; - setErrorMessage(errorCode); - // .. - }); + onSubmit: (values) => { + createUserWithEmailAndPassword(auth, values.email, values.password) + .then((userCredential) => { + // Signed up + const user = userCredential.user; + // console.log(user); + updateProfile(user, { + displayName: values.name, + }) + .then(() => { + const { uid, displayName, email } = auth.currentUser; + dispatch( + addUser({ uid: uid, displayName: displayName, email: email }) + ); - }, + sendEmailVerification(auth.currentUser).then(() => { + // Email verification sent! + // setSentEmail(true); + + toast({ + title: "Verify your Email", + description: "Verification email sent.", + }) + + // ... + }); + }) + .catch((error) => { + // An error occurred + setErrorMessage(error.code); + // ... + }); + + router.push("/"); + // ... + }) + .catch((error) => { + const errorCode = error.code; + const errorMessage = error.message; + setErrorMessage(errorCode); + // .. + }); + }, }); return ( @@ -107,26 +142,38 @@ const SignUpPage = () => {
Password
- -
{showPassword==='password'?:}
+ +
+ {showPassword === "password" ? : } +
- {formik.touched.password && formik.errors.password ? ( + {formik.touched.password && formik.errors.password ? (
*{formik.errors.password}!
) : null}
- {
{errorMessage}
} -