diff --git a/src/components/LoginAuth.jsx b/src/components/LoginAuth.jsx
index edf82e2..85dc070 100644
--- a/src/components/LoginAuth.jsx
+++ b/src/components/LoginAuth.jsx
@@ -1,7 +1,10 @@
import { Box, HStack, VStack, Image, Button } from "@chakra-ui/react";
import React, { useState } from "react";
+import { useNavigate } from "react-router-dom";
import {
DialogBody,
+ DialogHeader,
+ DialogTitle,
DialogContent,
DialogRoot,
DialogFooter,
@@ -19,6 +22,17 @@ const CardWithForm = ({ isAuthentificated }) => {
const [formType, setFormType] = useState("login");
const closeDialogRef = useRef(null); // Ref to programmatically trigger DialogCloseTrigger
+ const storedAuth = JSON.parse(localStorage.getItem("auth"));
+ const navigate = useNavigate();
+ /*const [isSignedIn, setIsSignedIn] = useState(() => {
+ return JSON.parse(localStorage.getItem("auth")) || false;
+ });*/
+
+ const handleLogout = () => {
+ localStorage.removeItem("auth"); // Clear auth data the logout api will be call here
+ navigate("/"); // Redirect to Home
+ };
+
const handleClose = () => {
if (closeDialogRef.current) {
closeDialogRef.current.click(); // Programmatically trigger close button
@@ -44,77 +58,116 @@ const CardWithForm = ({ isAuthentificated }) => {
}
};
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/* Left section with image */}
-
+ {storedAuth ? (
+
+
+
+
+
+
+
+
-
-
+ Confirm Logout
+
+
+
+ Are you sure you want to log out? Your session will be ended,
+ and you’ll need to sign in again to access your account.
+
+
+
+
+
+
+
+
+
+
+
+ ) : (
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* Left section with image */}
+
+
+
+
+
+ {/* Right section with form */}
+
+ {renderFormContent()}
+
+
+
+
+
+
-
-
- {/* Right section with form */}
-
- {renderFormContent()}
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ )}
+ >
);
};
diff --git a/src/views/ShareAProject.jsx b/src/views/ShareAProject.jsx
index 4ccc624..f7eadb5 100644
--- a/src/views/ShareAProject.jsx
+++ b/src/views/ShareAProject.jsx
@@ -1,205 +1,290 @@
-import React, { useState } from 'react'
+import React, { useState } from "react";
import "../styles/ShareAProject.css";
-import { Input, CheckboxGroup, Fieldset, Textarea, Button } from "@chakra-ui/react"
-import { Field } from "../components/ui/field"
-import { Checkbox } from "../components/ui/checkbox"
-import { Toaster, toaster } from "../components/ui/toaster"
+import {
+ Input,
+ CheckboxGroup,
+ Fieldset,
+ Textarea,
+ Button,
+} from "@chakra-ui/react";
+import { Field } from "../components/ui/field";
+import { Checkbox } from "../components/ui/checkbox";
+import { Toaster, toaster } from "../components/ui/toaster";
const ShareAProject = () => {
+ const [newProject, setNewProject] = useState({
+ title: "",
+ githubURL: "",
+ description: "",
+ frameworks: [],
+ liveDemoURL: "",
+ comments: "",
+ date: "",
+ });
- const [newProject, setNewProject] = useState({
- title: '',
- githubURL: '',
- description: '',
- frameworks: [],
- liveDemoURL: '',
- comments: '',
- date: ''
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+
+ try {
+ const response = await fetch("http://localhost:8001/addproject", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ ...newProject,
+ date: new Date().toISOString(),
+ }),
});
-
- const handleSubmit = async (e) => {
- e.preventDefault();
-
- try {
- const response = await fetch('http://localhost:8001/projects', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- ...newProject,
- date: new Date().toISOString()
- }),
- });
-
- if (response.ok) {
- toaster.create({
- title: 'Project submitted succesfully!',
- type: 'success',
- duration: 4000,
- action: {
- label: "x",
- }
- })
- setNewProject({
- title: '',
- githubURL: '',
- description: '',
- frameworks: [],
- liveDemoURL: '',
- comments: '',
- date: '',
- });
- } else {
- console.error('Failed to submit project');
- }
- } catch (error) {
- toaster.create({
- title: `Error submitting project: ${error.message}`,
- type: 'error',
- duration: 4000,
- action: {
- label: "x",
- }
- });
- }
- };
-
- const handleCheckboxChange = (value) => {
- setNewProject((prev) => ({
- ...prev,
- frameworks: prev.frameworks.includes(value)
- ? prev.frameworks.filter((framework) => framework !== value)
- : [...prev.frameworks, value],
- }));
- };
+ console.log(newProject);
+ if (response.ok) {
+ toaster.create({
+ title: "Project submitted succesfully!",
+ type: "success",
+ duration: 4000,
+ action: {
+ label: "x",
+ },
+ });
+ setNewProject({
+ title: "",
+ githubURL: "",
+ description: "",
+ frameworks: [],
+ liveDemoURL: "",
+ comments: "",
+ date: "",
+ });
+ } else {
+ console.error("Failed to submit project");
+ }
+ } catch (error) {
+ toaster.create({
+ title: `Error submitting project: ${error.message}`,
+ type: "error",
+ duration: 4000,
+ action: {
+ label: "x",
+ },
+ });
+ }
+ };
+
+ const handleCheckboxChange = (value) => {
+ setNewProject((prev) => ({
+ ...prev,
+ frameworks: prev.frameworks.includes(value)
+ ? prev.frameworks.filter((framework) => framework !== value)
+ : [...prev.frameworks, value],
+ }));
+ };
- return(
-