Skip to content

Commit

Permalink
firebase hosting
Browse files Browse the repository at this point in the history
  • Loading branch information
VinamraSaurav committed May 30, 2024
1 parent bab3056 commit 4331177
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 138 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -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
89 changes: 0 additions & 89 deletions public/index.html

This file was deleted.

3 changes: 2 additions & 1 deletion src/components/Nav/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import Link from "next/link";
import Image from "next/image";

import { AiFillOpenAI } from "react-icons/ai";



Expand All @@ -19,6 +19,7 @@ const Nav = () => {
alt="PromptGPT Logo"
className="object-contain"
/>
{/* <AiFillOpenAI className="text-4xl text-[#ff5722]"/> */}
<p className="max-sm:hidden font-satoshi font-semibold text-lg text-black dark:text-white tracking-wide">
PromptGPT
</p>
Expand Down
143 changes: 95 additions & 48 deletions src/components/SignUpPage.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,98 @@
"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"),
});

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 (
Expand Down Expand Up @@ -107,26 +142,38 @@ const SignUpPage = () => {
<div className="flex flex-col items-center justify-center mb-4">
<div className="font-popins text-sm w-64">Password</div>
<div className="flex w-64 justify-center items-center mx-auto">
<input
id="password"
type={showPassword}
placeholder="Enter Password"
required
onChange={formik.handleChange}
value={formik.values.password}
onBlur={formik.handleBlur}
className="w-64 py-2 px-1 m-1 bg-transparent text-sm font-popins border-b-2 border-black dark:border-white/30 outline-none"
></input>
<div className="absolute right-[35px] sm:right-[67px] cursor-pointer" onClick={handleShowPassword}>{showPassword==='password'?<IoEye/>:<IoMdEyeOff/>}</div>
<input
id="password"
type={showPassword}
placeholder="Enter Password"
required
onChange={formik.handleChange}
value={formik.values.password}
onBlur={formik.handleBlur}
className="w-64 py-2 px-1 m-1 bg-transparent text-sm font-popins border-b-2 border-black dark:border-white/30 outline-none"
></input>
<div
className="absolute right-[35px] sm:right-[67px] cursor-pointer"
onClick={handleShowPassword}
>
{showPassword === "password" ? <IoEye /> : <IoMdEyeOff />}
</div>
</div>
{formik.touched.password && formik.errors.password ? (
{formik.touched.password && formik.errors.password ? (
<div className="text-left text-red-600 text-xs w-60 mx-2 h-2 mb-2">
*{formik.errors.password}!
</div>
) : null}
</div>
{<div className="text-center flex h-3 mb-2 justify-center mx-auto text-red-600 text-xs w-60">{errorMessage}</div>}
<button type="submit" className="flex justify-center items-center mx-auto my-6 w-64 h-12 rounded-md bg-gradient-to-r from-amber-500 via-orange-600 to-yellow-500 text-white text-md font-popins font-bold cursor-pointer">
{
<div className="text-center flex h-3 mb-2 justify-center mx-auto text-red-600 text-xs w-60">
{errorMessage}
</div>
}
<button
type="submit"
className="flex justify-center items-center mx-auto my-6 w-64 h-12 rounded-md bg-gradient-to-r from-amber-500 via-orange-600 to-yellow-500 text-white text-md font-popins font-bold cursor-pointer"
>
SIGN UP
</button>
<div className="w-64 flex justify-start text-xs font-light mx-auto text-black/80 dark:text-white/80">
Expand Down

0 comments on commit 4331177

Please sign in to comment.