WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
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
67 changes: 67 additions & 0 deletions jetset/src/components/Admin/ChangePasswordForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { useState } from "react";
import axios from "axios";

const ChangePasswordForm = ({ touristId }) => {
const [oldPassword, setOldPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [message, setMessage] = useState("");

const handleChangePassword = async (e) => {
e.preventDefault();

if (newPassword !== confirmPassword) {
setMessage("New passwords do not match");
return;
}

try {
const response = await axios.put(`http://localhost:3000/cpAdmin/66fabf44cd7601258892778b`, {
oldPassword,
newPassword,
});
setMessage(response.data.message);
} catch (error) {
setMessage(error.response?.data.message || "Error updating password");
}
};

return (
<div>
<h2>Change Password</h2>
<form onSubmit={handleChangePassword}>
<label>
Old Password:
<input
type="password"
value={oldPassword}
onChange={(e) => setOldPassword(e.target.value)}
required
/>
</label>
<label>
New Password:
<input
type="password"
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
required
/>
</label>
<label>
Confirm New Password:
<input
type="password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
required
/>
</label>
<button type="submit">Change Password</button>
</form>
{message && <p>{message}</p>}
</div>
);
};

export default ChangePasswordForm;
14 changes: 14 additions & 0 deletions jetset/src/components/AdminFrontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import SortProducts from "./Products/SortProducts";
import DeleteAccount from "./Admin/DeleteAccount";
import CreateAdmin from "./Admin/CreateAdmin";
import CreateTourismGovernor from "./Admin/CreateTourismGovernor";
import ChangePasswordForm from "./Admin/ChangePasswordForm";

function AdminFrontend() {
// State for managing tags
Expand All @@ -41,6 +42,8 @@ function AdminFrontend() {
const [products, setProducts] = useState([]);
const [productLoading, setProductLoading] = useState(true);
const [productError, setProductError] = useState(null);
// State to manage ChangePasswordForm visibility
const [showChangePasswordForm, setShowChangePasswordForm] = useState(false);

// Fetch tags from the backend
const fetchTags = async () => {
Expand Down Expand Up @@ -113,6 +116,17 @@ function AdminFrontend() {
) : (
<p>No tags available to update, delete, or display.</p>
)}


{/* Button to toggle ChangePasswordForm */}
<button onClick={() => setShowChangePasswordForm(!showChangePasswordForm)}>
{showChangePasswordForm ? "Hide Change Password" : "Change Password"}
</button>

{/* Conditionally render ChangePasswordForm */}
{showChangePasswordForm && <ChangePasswordForm />}


{/* Category Management Section */}
<h2>Category Management</h2>
{categoryLoading && <p>Loading categories...</p>}
Expand Down
67 changes: 67 additions & 0 deletions jetset/src/components/Advertiser/ChangePasswordForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { useState } from "react";
import axios from "axios";

const ChangePasswordForm = ({ touristId }) => {
const [oldPassword, setOldPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [message, setMessage] = useState("");

const handleChangePassword = async (e) => {
e.preventDefault();

if (newPassword !== confirmPassword) {
setMessage("New passwords do not match");
return;
}

try {
const response = await axios.put(`http://localhost:3000/cpAdvertiser/6701a2e8077eb6e57b56801f`, {
oldPassword,
newPassword,
});
setMessage(response.data.message);
} catch (error) {
setMessage(error.response?.data.message || "Error updating password");
}
};

return (
<div>
<h2>Change Password</h2>
<form onSubmit={handleChangePassword}>
<label>
Old Password:
<input
type="password"
value={oldPassword}
onChange={(e) => setOldPassword(e.target.value)}
required
/>
</label>
<label>
New Password:
<input
type="password"
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
required
/>
</label>
<label>
Confirm New Password:
<input
type="password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
required
/>
</label>
<button type="submit">Change Password</button>
</form>
{message && <p>{message}</p>}
</div>
);
};

export default ChangePasswordForm;
23 changes: 23 additions & 0 deletions jetset/src/components/Advertiser/DeleteAccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// src/DeleteAccount.js
import React from 'react';
import axios from 'axios';

const DeleteAccount = ({ advertiserId }) => {

const handleDeleteAccount = async () => {
try {
const response = await axios.delete(`http://localhost:3000/deleteAccAdvertiser/6707bb596d08e5f1f78e31f1`);
alert(response.data.message); // Show success message
} catch (err) {
alert(err.response?.data?.message || "An error occurred"); // Show error message
}
};

return (
<div>
<button onClick={handleDeleteAccount}>Delete Account</button>
</div>
);
};

export default DeleteAccount;
14 changes: 14 additions & 0 deletions jetset/src/components/Advertiser/ProfileAdvertiser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useState, useEffect } from "react";
import axios from "axios";
import ActivityForm from "../Activity/ActivityProfileAdv"; // Import ActivityForm
import ChangePasswordForm from "./ChangePasswordForm";
import DeleteAccount from "./DeleteAccount";

const ProfileForm = ({ onProfileCreated }) => {
const BASE_URL = process.env.REACT_APP_BASE_URL || "http://localhost:3000";
Expand All @@ -25,6 +27,7 @@ const ProfileForm = ({ onProfileCreated }) => {
const [profiles, setProfiles] = useState([]); // State to store profiles
const [isFetchingProfiles, setIsFetchingProfiles] = useState(false); // State to indicate fetching
const [selectedAdvertiserId, setSelectedAdvertiserId] = useState(null); // For selected advertiser ID
const [showChangePassword, setShowChangePassword] = useState(false); // State to toggle ChangePasswordForm

// Fetch profiles when the component mounts
useEffect(() => {
Expand Down Expand Up @@ -234,6 +237,17 @@ const ProfileForm = ({ onProfileCreated }) => {
console.log("Activity created:", activity);
}}
/>

{/* Button to toggle ChangePasswordForm */}
<button onClick={() => setShowChangePassword(!showChangePassword)}>
{showChangePassword ? "Hide Change Password" : "Change Password"}
</button>

{/* Conditionally render the ChangePasswordForm */}
{showChangePassword && <ChangePasswordForm />}

<DeleteAccount advertiserId="6707bb596d08e5f1f78e31f1" />

</div>
);
};
Expand Down
3 changes: 3 additions & 0 deletions jetset/src/components/Place.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PlaceForm from "./Place/PlaceForm";
import TagForm from "./Tag/TagForm";
import ActivitiesList from "./Activity/ActivityListAdv";
import ItineraryList from "./Itinerary/ItinerariesList";
import ChangePasswordForm from "./Place/ChangePasswordForm";

const PlaceManagement = () => {
return (
Expand All @@ -15,6 +16,8 @@ const PlaceManagement = () => {
<TagForm />
<ActivitiesList />
<ItineraryList />
<h1>Change Password</h1>
<ChangePasswordForm />
</div>
);
};
Expand Down
67 changes: 67 additions & 0 deletions jetset/src/components/Place/ChangePasswordForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { useState } from "react";
import axios from "axios";

const ChangePasswordForm = ({ touristId }) => {
const [oldPassword, setOldPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [message, setMessage] = useState("");

const handleChangePassword = async (e) => {
e.preventDefault();

if (newPassword !== confirmPassword) {
setMessage("New passwords do not match");
return;
}

try {
const response = await axios.put(`http://localhost:3000/cpTourismgoverner/67236bbdb4febd354fcca5e2`, {
oldPassword,
newPassword,
});
setMessage(response.data.message);
} catch (error) {
setMessage(error.response?.data.message || "Error updating password");
}
};

return (
<div>
<h2>Change Password</h2>
<form onSubmit={handleChangePassword}>
<label>
Old Password:
<input
type="password"
value={oldPassword}
onChange={(e) => setOldPassword(e.target.value)}
required
/>
</label>
<label>
New Password:
<input
type="password"
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
required
/>
</label>
<label>
Confirm New Password:
<input
type="password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
required
/>
</label>
<button type="submit">Change Password</button>
</form>
{message && <p>{message}</p>}
</div>
);
};

export default ChangePasswordForm;
2 changes: 1 addition & 1 deletion jetset/src/components/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Register = () => {

// Navigate to the appropriate page based on role selection
if (selectedRole === "tourist") {
navigate("/touristregister"); // Navigate to Tourist register page
navigate("/tourist"); // Navigate to Tourist register page
} else if (selectedRole === "admin") {
navigate("/admin"); // Navigate to Admin page
} else if (selectedRole === "seller") {
Expand Down
Loading