diff --git a/Backend/controllers/pharmacyController.js b/Backend/controllers/pharmacyController.js
index dc89321f..0312ecc9 100644
--- a/Backend/controllers/pharmacyController.js
+++ b/Backend/controllers/pharmacyController.js
@@ -173,7 +173,9 @@ exports.toggleClosingStatus = async (req, res) => {
// @desc post pharmacy Forgot password
// @route POST /api/pharmacies/forgot-password
exports.forgotPassword = async (req, res) => {
- const pharmacy = await pharmacy.findOne({ email: req.body.email.trim().toLowerCase() });
+ const pharmacy = await pharmacy.findOne({
+ email: req.body.email.trim().toLowerCase(),
+ });
if (!pharmacy) {
return res.status(404).json({ message: "Pharmacy not found" });
}
@@ -204,8 +206,7 @@ exports.forgotPassword = async (req, res) => {
message: "Error sending email. Please try again later.",
});
}
-}
-
+};
// @desc patch pharmacy reset password
// @route PATCH /api/pharmacies/reset-password/:token
@@ -221,17 +222,17 @@ exports.resetPassword = async (req, res) => {
passwordResetToken: hashedToken,
passwordResetExpires: { $gt: Date.now() },
});
-
+
if (!pharmacy) {
return res.status(400).json({ message: "Invalid or expired token" });
}
-
+
pharmacy.password = req.body.password;
pharmacy.passwordResetToken = undefined;
pharmacy.passwordResetExpires = undefined;
-
+
await pharmacy.save();
-
+
res.status(200).json({ message: "Password reset successful" });
//login pharmacy
const loginToken = generateToken(pharmacy);
@@ -240,6 +241,6 @@ exports.resetPassword = async (req, res) => {
token: loginToken,
});
} catch (err) {
- res.status(500).json({message: "Server error", error: err.message });
+ res.status(500).json({ message: "Server error", error: err.message });
}
-}
\ No newline at end of file
+};
diff --git a/Frontend/.gitignore b/Frontend/.gitignore
index a547bf36..5c0b45a0 100644
--- a/Frontend/.gitignore
+++ b/Frontend/.gitignore
@@ -22,3 +22,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?
+
+# Ignore the .env file
+.env
diff --git a/Frontend/src/App.jsx b/Frontend/src/App.jsx
index 1c2dbc0a..7eb1b5c8 100644
--- a/Frontend/src/App.jsx
+++ b/Frontend/src/App.jsx
@@ -17,11 +17,12 @@ import OrderSummary from "./pages/OrderSummary";
// import ProfileSignup from "./pages/ProfileSignup";
import FindMedsLoading from "./components/FindMedsLoading";
import UpdatedCart from "./pages/UpdatedCart";
-import PhamarcySignUp from "./components/forms/PhamarcySignUp";
+import NewPharmarcySignUp from "./components/forms/NewPharmarcySignUp";
import MedicineTable from "./components/MedicineTable";
import UploadPrescription from "./pages/UploadPrescription";
import PharmacyOtp from "./components/PharmacyOtp";
import OtpConfirmed from "./components/OtpConfirmed";
+import Pharmarcysignin from "./components/forms/Pharmarcysignin";
// Code splitted Components (Lazy Loading)...
// N.B- Please do not touch if you're new to how lazy loading works..
@@ -133,7 +134,8 @@ function App() {
{/* Pharmacy Routing */}
} />
} />
- } />
+ } />
+ } />
} />
} />
} />
diff --git a/Frontend/src/components/forms/NewPharmarcySignUp.jsx b/Frontend/src/components/forms/NewPharmarcySignUp.jsx
new file mode 100644
index 00000000..8ed1ad11
--- /dev/null
+++ b/Frontend/src/components/forms/NewPharmarcySignUp.jsx
@@ -0,0 +1,170 @@
+import React, { useState } from "react";
+import styles from "../../styles/newpharmacysignup.module.css";
+import caretleft from "../../assets/CaretLeft.png";
+import cancelicon from "../../assets/X.png";
+
+const InputField = ({ id, name, type, placeholder, value, onChange }) => (
+
+);
+
+const NewPharmarcySignUp = () => {
+ const [formData, setFormData] = useState({
+ name: "",
+ email: "",
+ password: "",
+ confirmPassword: "",
+ phone: "",
+ address: "",
+ });
+
+ const [error, setError] = useState("");
+ const [success, setSuccess] = useState(false);
+ const [loading, setLoading] = useState(false);
+
+ const handleChange = (e) => {
+ const { name, value } = e.target;
+ setFormData({ ...formData, [name]: value });
+ };
+
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+ setError("");
+ setSuccess(false);
+
+ // Basic validation
+ if (
+ !formData.name ||
+ !formData.email ||
+ !formData.password ||
+ !formData.confirmPassword ||
+ !formData.phone ||
+ !formData.address
+ ) {
+ setError("All fields are required.");
+ return;
+ }
+
+ if (formData.password !== formData.confirmPassword) {
+ setError("Passwords do not match.");
+ return;
+ }
+
+ setLoading(true);
+
+ try {
+ const response = await fetch(
+ `${import.meta.env.VITE_API_URL}/pharmacies/signup`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(formData),
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to sign up. Please try again.");
+ }
+
+ const data = await response.json();
+ setSuccess(true);
+ setFormData({
+ name: "",
+ email: "",
+ password: "",
+ confirmPassword: "",
+ phone: "",
+ address: "",
+ });
+ } catch (err) {
+ setError(err.message);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+
+
+
+

+
Create Account
+

+
+
+
+
Already have an account?
+
Log in
+
+
+
+ );
+};
+
+export default NewPharmarcySignUp;
diff --git a/Frontend/src/components/forms/PhamarcySignUp.jsx b/Frontend/src/components/forms/PhamarcySignUp.jsx
deleted file mode 100644
index f9360ab5..00000000
--- a/Frontend/src/components/forms/PhamarcySignUp.jsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import React from "react";
-import "../../styles/pharmacysignup.css";
-import caretleft from "../../assets/CaretLeft.png";
-import cancelicon from "../../assets/X.png"
-const PhamarcySignUp = () => {
- return (
-
-
-

-

-
-
-
- {" "}
-
Already have An Account
-
Login in
-
-
- );
-};
-
-export default PhamarcySignUp;
diff --git a/Frontend/src/components/forms/PharmacyLogin.jsx b/Frontend/src/components/forms/PharmacyLogin.jsx
deleted file mode 100644
index 53ed4ff9..00000000
--- a/Frontend/src/components/forms/PharmacyLogin.jsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import React from 'react'
-import "./../../styles/pharmacylogin.css"
-import caretleft from "../../assets/CaretLeft.png";
-import cancelicon from "../../assets/X.png"
-const PharmacyLogin = () => {
-return (
-
-)
-}
-
-export default PharmacyLogin
\ No newline at end of file
diff --git a/Frontend/src/components/forms/Pharmarcysignin.jsx b/Frontend/src/components/forms/Pharmarcysignin.jsx
new file mode 100644
index 00000000..cfeb306b
--- /dev/null
+++ b/Frontend/src/components/forms/Pharmarcysignin.jsx
@@ -0,0 +1,130 @@
+import React, { useState } from "react";
+import styles from "../../styles/pharmacysignin.module.css";
+import caretleft from "../../assets/CaretLeft.png";
+import cancelicon from "../../assets/X.png";
+import { useNavigate } from "react-router-dom";
+
+const Pharmarcysignin = () => {
+ const [email, setEmail] = useState("");
+ const [password, setPassword] = useState("");
+ const [rememberMe, setRememberMe] = useState(false);
+ const [error, setError] = useState("");
+
+ const handleSignIn = async (e) => {
+ // Prevent Default submission
+ e.preventDefault();
+ setError("");
+
+ try {
+ const response = await fetch(
+ // "https://new-cura.onrender.com/api/pharmacies/signin",
+ `${import.meta.env.VITE_API_URL}/pharmacies/signin`,
+
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ email, password }),
+ }
+ );
+
+ const data = await response.json();
+
+ if (response.ok) {
+ localStorage.setItem("authtoken", data.token);
+ navigate("/dashboard");
+ } else if (response.status === 401) {
+ const data = await response.json();
+ setError(data.message || "Invalid email or password.");
+ } else if (response.status === 404) {
+ setError("Account not found. Please check your email.");
+ } else {
+ setError(data.message || "Sign-in failed. Please try again.");
+ }
+ } catch (error) {
+ setError("Network error. Please try again later.");
+ console.error("Sign-in error:", error);
+ }
+ };
+
+ const navigate = useNavigate();
+
+ const handleSignUp = () => {
+ navigate("/signup-email");
+ };
+
+ const handleSubmit = (e) => {
+ e.preventDefault();
+ };
+ return (
+
+
+
+

+
Log In
+

+
+
+
+
Don't have an account?
+
Sign up
+
+
+
+ );
+};
+
+export default Pharmarcysignin;
diff --git a/Frontend/src/components/forms/SignIn.jsx b/Frontend/src/components/forms/SignIn.jsx
index bbc47f4a..19e3158c 100644
--- a/Frontend/src/components/forms/SignIn.jsx
+++ b/Frontend/src/components/forms/SignIn.jsx
@@ -16,7 +16,8 @@ const SignIn = () => {
try {
const response = await fetch(
- "https://new-cura.onrender.com/api/patients/signin",
+ `${import.meta.env.VITE_API_URL}/patients/signin`,
+
{
method: "POST",
headers: {
@@ -95,7 +96,7 @@ const SignIn = () => {
/>
Remember Me
- Forgot password?
+ Forgot password?