Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved issue 393 #406

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/pages/AddFoodItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function AddFoodItem() {
break;
case "Dinner":
apiUrl = `${process.env.REACT_APP_BASE_URL}/${canteenId}/dinner/add`;
console.log("This is api url",apiUrl);
break;
default:
toast.error("Please select a meal type.");
Expand Down Expand Up @@ -103,7 +104,8 @@ function AddFoodItem() {
};

return (
<div className={`flex justify-center items-center h-[auto] ${theme === 'dark' ? 'bg-[#131b33]' : 'bg-white'}`}>
<div className={`flex py-10 justify-center items-center h-[80vh] ${theme === 'dark' ? 'bg-[#131b33]' : 'bg-white'}`}>

<form
onSubmit={handleSubmit}
className={`p-6 rounded shadow-lg w-full max-w-sm mt-[40px] mb-[20px] border-2 ${theme === 'dark' ? 'bg-gray-300' : 'bg-white'}`}
Expand Down
68 changes: 44 additions & 24 deletions src/pages/EditProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import React, { useState, useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import Navbar from '../components/Navbar';
import Footer from '../components/Footer';

import { MdEdit } from "react-icons/md";
import { FaArrowAltCircleLeft } from "react-icons/fa";
const EditProfile = () => {
const { _id } = useParams(); // Assuming you have canteen ID in the URL
const navigate = useNavigate(); // useNavigate hook for navigation
const [edit, setEditable] = useState(false);
const [editName, setEditName] = useState(false);
const [editEmail, setEditEmail] = useState(false);
const [editCollegeName, setEditCollegeName] = useState(false);
const [editImage, setEditImage] = useState(false);
const [formData, setFormData] = useState({
name: '',
email: '',
Expand Down Expand Up @@ -93,98 +98,113 @@ const EditProfile = () => {
return (
<>
<Navbar/>
<div className="relative min-h-screen pt-[120px] flex flex-col items-center justify-center dark:bg-gray-100">
<div className="relative min-h-screen pt-[120px] flex flex-col items-center justify-center dark:bg-gray-100 text-black ">
<h2 className="text-4xl text-white font-bold mb-8 dark:text-black">Edit Profile</h2>
<button
className="absolute top-[120px] right-[80px] mb-4 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
className="absolute top-[120px] right-[80px] mb-4 flex gap-3 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full focus:outline-none focus:shadow-outline"
onClick={() => navigate(`/section/${_id}`)}
>
<FaArrowAltCircleLeft/>
Back
</button>
<form className="w-full max-w-lg bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4" onSubmit={handleSubmit}>
<div className="mb-4">
<label className="block text-gray-700 text-sm font-bold mb-2" htmlFor="name">
Canteen Name
</label>
<input
<div className='flex flex-row justify-between bg-white text-black border rounded-full px-4 py-2 shadow ' >
<input
type="text"
name="name"
value={formData.name}
disabled={!edit}
disabled={!editName}
onChange={handleChange}
className={`shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline `}

className=" appearance-none border-none rounded w-full py-2 px-3 text-gray-700 leading-tight outline-none"

/>
<MdEdit className=' text-2xl self-center cursor-pointer' onClick={() => setEditName(!editName)} />
</div>
</div>
<div className="mb-4">
<label className="block text-gray-700 text-sm font-bold mb-2" htmlFor="email">
Email
</label>
<input
<div className='flex flex-row justify-between bg-white text-black border rounded-full px-4 py-2 shadow ' >
<input
type="email"
name="email"
disabled={!edit}
value={formData.email}
disabled={!editEmail}
onChange={handleChange}
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
className=" appearance-none border-none rounded w-full py-2 px-3 text-gray-700 leading-tight outline-none"
/>
<MdEdit className=' text-2xl self-center cursor-pointer' onClick={() => setEditEmail(!editEmail)} />
</div>
</div>
<div className="mb-4">
<label className="block text-gray-700 text-sm font-bold mb-2" htmlFor="collegeName">
College Name
</label>
<input
<div className='flex flex-row justify-between bg-white text-black border rounded-full px-4 py-2 shadow ' >
<input
type="text"
name="collegeName"
disabled={!edit}
value={formData.collegeName}
disabled={!editCollegeName}
onChange={handleChange}
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
className=" appearance-none border-none rounded w-full py-2 px-3 text-gray-700 leading-tight outline-none"
/>
<MdEdit className=' text-2xl self-center cursor-pointer' onClick={() => setEditCollegeName(!editCollegeName)} />
</div>
</div>
<div className="mb-6">
<label className="block text-gray-700 text-sm font-bold mb-2" htmlFor="canteenImage">
Canteen Image
</label>
<input
<div className='flex flex-row justify-between bg-white text-black border rounded-full px-4 py-2 shadow ' >
<input
type="file"
accept="image/*"
disabled={!edit}
onChange={handleImageChange}
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
accept='image/*'
disabled={!editImage}
onChange={handleChange}
className=" appearance-none border-none rounded w-full py-2 px-3 text-gray-700 leading-tight outline-none"
/>
<MdEdit className=' text-2xl self-center cursor-pointer' onClick={() => setEditImage(!editImage)} />
</div>
{formData.canteenImage ? (
<img src={formData.canteenImage} alt="Canteen" className="mt-4 w-32 h-32 object-cover rounded" />
) : (
<p className="mt-4 text-gray-700">No image available</p>
)}
</div>
<div className="flex items-center justify-between">
{!edit && (
{/* {!edit && (
<button
type="button"
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
onClick={() => setEditable(true)}
>
Edit
</button>
)}
{edit && (
)} */}

<>
<button
disabled={!editName && !editEmail && !editCollegeName && !editImage}
type="submit"
className="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
className="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-full focus:outline-none focus:shadow-outline"
>
Save
Save Change
</button>
<button
type="button"
className="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
className="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded-full focus:outline-none focus:shadow-outline"
onClick={() => setEditable(false)}
>
Cancel
</button>
</>
)}
</div>
</form>

Expand Down
2 changes: 2 additions & 0 deletions src/pages/SectionPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ const SectionPage = () => {
Product List <CiBoxList />
</button>
</div>
<div className={ ` py-[10%] ${theme === 'dark' ? 'bg-[#131b33]' : 'bg-white'}` }>
{view === "add" ? <AddFoodItem /> : <Foodlist />}
</div>
</>
)}
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ function Signup() {
// : `${process.env.REACT_APP_BASE_URL}/canteenSignup`;
const apiUrl = formData.accountType === "User"

? 'http://localhost:4000/api/v1/studentSignup' : 'http://localhost:4000/api/v1/canteenSignup'
? 'http://localhost:8000/api/v1/studentSignup' : 'http://localhost:8000/api/v1/canteenSignup'



try {
setLoading(true);

const response = await axios.post(apiUrl, formData);

console.log("This is response", response.data);

toast.success("Account Created Successfully!");

Expand Down