Guest User

Untitled

a guest
Dec 30th, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. "use client";
  2. import { withPageAuthRequired, getSession } from "@auth0/nextjs-auth0";
  3. import { useEffect, useState } from "react";
  4.  
  5. export default withPageAuthRequired(
  6. function Dashboard() {
  7. const savedPrompts = [
  8. {
  9. id: 1,
  10. prompt: "Write a blog post about AI advancements",
  11. use: "Blogging",
  12. },
  13. {
  14. id: 2,
  15. prompt: "Create a story set in a futuristic world",
  16. use: "Story Writing",
  17. },
  18. // ... other saved prompts
  19. ];
  20. const [prompt, setPrompt] = useState("");
  21. const [promptUse, setPromptUse] = useState("");
  22. const [superPrompt, setSuperPrompt] = useState("");
  23. const handleSubmit = (event) => {
  24. event.preventDefault();
  25. fetch("/api/handleSubmit", {
  26. method: "POST",
  27. headers: {
  28. "content-type": "application/json",
  29. },
  30. body: JSON.stringify({ prompt, promptUse, superPrompt }),
  31. });
  32. };
  33.  
  34. return (
  35. <div className="container mx-auto px-4 py-8">
  36. <h1 className="text-3xl font-semibold mb-6">
  37. Create Your Super Prompt
  38. </h1>
  39. <div className="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
  40. <form onSubmit={handleSubmit}>
  41. <div className="mb-4">
  42. <label
  43. className="block text-gray-700 text-sm font-bold mb-2"
  44. htmlFor="prompt">
  45. Your Initial Prompt
  46. </label>
  47. <input
  48. className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
  49. id="prompt"
  50. type="text"
  51. placeholder="Write a blog post"
  52. value={prompt}
  53. onChange={(e) => setPrompt(e.target.value)}
  54. />
  55. </div>
  56. <div className="mb-6">
  57. <label
  58. className="block text-gray-700 text-sm font-bold mb-2"
  59. htmlFor="prompt-use">
  60. What will the prompt be used for?
  61. </label>
  62. <input
  63. className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
  64. id="prompt-use"
  65. type="text"
  66. placeholder="E.g., Blogging, Story Writing, etc."
  67. value={promptUse}
  68. onChange={(e) => setPromptUse(e.target.value)}
  69. />
  70. </div>
  71. <div className="mb-6">
  72. <label
  73. className="block text-gray-700 text-sm font-bold mb-2"
  74. htmlFor="super-prompt">
  75. Super Prompt Requirement
  76. </label>
  77. <textarea
  78. className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
  79. id="super-prompt"
  80. placeholder="Describe your requirements for the super prompt"
  81. value={superPrompt}
  82. onChange={(e) => setSuperPrompt(e.target.value)}></textarea>
  83. </div>
  84. <div className="flex items-center justify-between">
  85. <button
  86. className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
  87. type="submit">
  88. Generate Super Prompt
  89. </button>
  90. </div>
  91. </form>
  92. </div>
  93.  
  94. <div className="mt-10">
  95. <h2 className="text-2xl font-semibold mb-4">Your Saved Prompts</h2>
  96. <div className="bg-white shadow-md rounded px-8 pt-6 pb-8">
  97. {savedPrompts.length > 0 ? (
  98. <ul>
  99. {savedPrompts.map((prompt) => (
  100. <li key={prompt.id} className="border-b border-gray-200 py-3">
  101. <p className="text-lg font-semibold">{prompt.prompt}</p>
  102. <p className="text-sm text-gray-600">Use: {prompt.use}</p>
  103. </li>
  104. ))}
  105. </ul>
  106. ) : (
  107. <p>No saved prompts yet.</p>
  108. )}
  109. </div>
  110. </div>
  111. </div>
  112. );
  113. },
  114. { returnTo: "/profile" }
  115. );
  116.  
Advertisement
Add Comment
Please, Sign In to add comment