-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6eb2c83
commit 949e32f
Showing
24 changed files
with
1,156 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MONGODB_URI=mongodb+srv://admin-uwais:password%[email protected]/?retryWrites=true&w=majority |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import User from "../../../models/user.js"; | ||
import { connectToDB } from "@utils/database.js"; | ||
|
||
export const POST = async (request, res) => { | ||
try { | ||
const requestData = await request.json(); | ||
const { email } = requestData; | ||
console.log(email); | ||
|
||
await connectToDB(); | ||
|
||
const userExists = await User.findOne({ email: email }); | ||
|
||
if (userExists) { | ||
return new Response( | ||
JSON.stringify({ message: "Successfully signed In" }), | ||
{ | ||
status: 201, | ||
} | ||
); | ||
} else { | ||
return new Response(JSON.stringify({ message: "Please Sign Up" }), { | ||
status: 200, | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
return new Response("Failed to sign in", { status: 500 }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import User from "../../../models/user.js"; | ||
import { connectToDB } from "@utils/database.js"; | ||
|
||
export const POST = async (request, res) => { | ||
try { | ||
const requestData = await request.json(); | ||
const { name, email, phone } = requestData; | ||
console.log(name, email, phone); | ||
|
||
await connectToDB(); | ||
|
||
const userExists = await User.findOne({ email: email }); | ||
|
||
if (!userExists) { | ||
await User.create({ | ||
name: name, | ||
email: email, | ||
phone: phone, | ||
}); | ||
|
||
return new Response(JSON.stringify({ message: "User created" }), { | ||
status: 201, | ||
}); | ||
} else { | ||
return new Response(JSON.stringify({ message: "User already exists" }), { | ||
status: 200, | ||
}); | ||
} | ||
|
||
// const newUser = new User({ name, email, phone }); | ||
// await newUser.save(); | ||
// return new Response(JSON.stringify({ message: "User created" }), { status: 201 }); | ||
} catch (error) { | ||
console.error(error); | ||
return new Response("Failed to create a new prompt", { status: 500 }); | ||
} | ||
}; |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import "@styles/globals.css"; | ||
import Provider from "@components/Provider"; | ||
|
||
export const metadata = { | ||
title: "Promptopia", | ||
description: "Discover & Share AI Prompts", | ||
}; | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body> | ||
<main>{children}</main> | ||
</body> | ||
</html> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client"; | ||
import Form from "../components/Form"; | ||
import { useState } from "react"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
const Home = () => { | ||
const handleSignUpInputChange = async (e) => { | ||
const { name, value } = e.target; | ||
setFormData((prevData) => ({ ...prevData, [name]: value })); | ||
}; | ||
|
||
const handleSignUpSubmit = async (e) => { | ||
e.preventDefault(); | ||
try { | ||
const response = await fetch("/api/submit-form", { | ||
method: "POST", | ||
body: JSON.stringify({ | ||
name: formData.name, | ||
email: formData.email, | ||
phone: formData.phone, | ||
}), | ||
}); | ||
|
||
if (response.status === 201) { | ||
router.push("/profile"); | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
|
||
const [formData, setFormData] = useState({ | ||
name: "", | ||
email: "", | ||
phone: "", | ||
}); | ||
|
||
const router = useRouter(); | ||
|
||
return ( | ||
<section className="w-full flex-center flex-col"> | ||
<h1 className="head_text text-center"> | ||
Discover & Share | ||
<br className="max-md:hidden" /> | ||
<span className="orange_gradient text-center"> AI-Powered Prompts</span> | ||
</h1> | ||
<p className="desc text-center"> | ||
Promptopia is an open-source AI prompting tool for modern world to | ||
discover, create and share creative prompts | ||
</p> | ||
<Form onChange={handleSignUpInputChange} onSubmit={handleSignUpSubmit} /> | ||
</section> | ||
); | ||
}; | ||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from "react"; | ||
import Nav from "@components/Navbar"; | ||
|
||
const Profile = () => { | ||
return ( | ||
<div> | ||
<Nav /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Profile; |
Oops, something went wrong.