Skip to content

Commit

Permalink
Merge branch 'profile' of https://github.com/ridabensalem/tour-trek i…
Browse files Browse the repository at this point in the history
…nto profile

test
  • Loading branch information
AmineBaray committed Jun 7, 2024
2 parents bf7d3d2 + 2ebfe6f commit 0fb810f
Show file tree
Hide file tree
Showing 6 changed files with 908 additions and 66 deletions.
196 changes: 164 additions & 32 deletions app/components/profile/security.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,169 @@
import React from 'react';
'use client'
import { useState } from 'react';
import ProfileFrameElement from './profileFrame';

const Security = () => {
return (
<ProfileFrameElement text="Security">
<div className="mx-auto px-8 bg-white">
<p className="text-black mb-4 pl-6">
Manage your security settings, set up secure authentication, or delete your account.
</p>
<div className="mb-6">
<div className="flex justify-between items-center mb-2">
<label className="text-gray-400 font-semibold">Password</label>
<button className="bg-pink-500 text-white py-1 px-3 rounded">Reset</button>
</div>
<p className="text-zinc-500 text-sm mb-4 border-b-2 border-gray-300">Last updated on 1 day ago</p>
<input type="password" placeholder="Current Password" className="w-full mb-2 p-2 border border-zinc-300 dark:border-zinc-700 rounded" />
<input type="password" placeholder="New Password" className="w-full mb-2 p-2 border border-zinc-300 dark:border-zinc-700 rounded" />
<input type="password" placeholder="Confirm New Password" className="w-full mb-2 p-2 border border-zinc-300 dark:border-zinc-700 rounded" />
</div>
<div className="mb-6">
<div className="flex justify-between items-center mb-2">
<label className="text-zinc-900 font-semibold">Recovery Phone</label>
<button className="bg-pink-500 text-white py-1 px-3 rounded">Add</button>

const Security = () => {
const [showPasswordInputs, setShowPasswordInputs] = useState(false);
const [showRecoveryInput, setShowRecoveryInput] = useState(false);
const [showDeleteAccountForm, setShowDeleteAccountForm] = useState(false);
const [showFeedbackTextarea, setShowFeedbackTextarea] = useState(false);

const togglePasswordInputs = () => {
setShowPasswordInputs(prevState => !prevState);
};

const toggleRecoveryInput = () => {
setShowRecoveryInput(prevState => !prevState);
};

const toggleDeleteAccountForm = () => {
setShowDeleteAccountForm(prevState => !prevState);
};

const handleContinue = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
setShowFeedbackTextarea(true);
};

const handleBack = () => {
setShowFeedbackTextarea(false);
};

return (
<ProfileFrameElement text="Security">

<div className="py-2 w-full mx-auto bg-white space-y-6 mb-4 px-6">
<p className="text-base font-bold">
Manage your security settings, set up secure authentication, or delete your account.
</p>

<div className="space-y-2">
<div className="flex justify-between items-center">
<div>
<h2 className="text-lg font-semibold mt-4">Password</h2>
<p className="text-base text-zinc-500 dark:text-zinc-400 border-b-2 w-[360px]">Last updated on 1 day ago</p>
</div>
<button
onClick={togglePasswordInputs}
className="bg-pink-500 text-white px-4 py-2 rounded-md relative top-2 w-[70px]"
>
{showPasswordInputs ? 'Hide' : 'Reset'}
</button>
</div>

{showPasswordInputs && (
<div className="space-y-2 w-[350px] mx-auto">
<input
type="password"
placeholder="Current Password"
className="w-full px-4 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md focus:border-pink-500 focus:outline-none"
/>
<input
type="password"
placeholder="New Password"
className="w-full px-4 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md focus:border-pink-500 focus:outline-none"
/>
<input
type="password"
placeholder="Confirm New Password"
className="w-full px-4 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md focus:border-pink-500 focus:outline-none"
/>
<button
className="bg-[#162448] text-white px-4 py-2 rounded-md relative top-2"
>
Update password
</button>
</div>
)}
</div>

<div className="space-y-2 mt-2">
<div className="flex justify-between items-center">
<div >
<h2 className="text-lg font-semibold">Recovery Email</h2>
<p className="text-base text-zinc-500 dark:text-zinc-400 border-b-2 w-[360px]">example@gmail.com</p>
</div>
<button
onClick={toggleRecoveryInput}
className="bg-pink-500 text-white px-4 py-2 rounded-md w-[70px]"
>
{showRecoveryInput ? 'Hide' : 'Add'}
</button>
</div>

{showRecoveryInput && (
<div className="space-y-2 w-[350px] mx-auto">
<input
type="text"
placeholder="example@gmail.com"
className="w-full px-4 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md focus:border-pink-500 focus:outline-none"
/>
<button
className="bg-[#2C63EB] text-white px-4 py-2 rounded-md "
>
Add
</button>
</div>
)}
</div>

<div className="space-y-2 mt-2">
<div>
<h2 className="text-lg font-semibold">Delete Account</h2>
<p className="text-base text-zinc-500 dark:text-zinc-400 border-b-2 w-[358px]">
Permanently delete your tourTrek.com account
<button
onClick={toggleDeleteAccountForm}
className="ml-2"
>
{showDeleteAccountForm ? '▼' : '▶'}
</button>
</p>
</div>

{showDeleteAccountForm && !showFeedbackTextarea && (
<div className="border-2 border-zinc-200 p-4 rounded-md">
<div className="flex items-center justify-between">
<p className="text-lg">Why do you want to delete your account?</p>
</div>
<form className="mt-4" onSubmit={handleContinue}>
<div className="flex items-center mb-2">
<input id="option1" type="radio" name="reason" className="text-blue-600" />
<label className="ml-2 text-zinc-700">I get too many emails from TourTrek.com</label>
</div>
<div className="flex items-center mb-2">
<input id="option2" type="radio" name="reason" className="text-blue-600" />
<label className="ml-2 text-zinc-700">Privacy concerns</label>
</div>
<div className="flex items-center mb-4">
<input id="option3" type="radio" name="reason" className="text-blue-600" />
<label className="ml-2 text-zinc-700">I want to remove all my data</label>
</div>
<button type="submit" className="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 relative left-[400px]">Continue</button>
</form>
</div>
)}

{showFeedbackTextarea && (
<div>
<button onClick={handleBack} className="text-pink-500 mb-2 relative right-0">← Back</button>
<div className="rounded-md flex flex-col items-end">
<textarea
name="textarea"
minLength={10}
maxLength={30}
className="w-full h-32 px-4 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md focus:border-pink-500 focus:outline-none"
placeholder="Do you have any feedback you'd like to share before you go? We'll use it to fix problems and improve our services..."
/>
<button type="submit" className="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 mt-2">Delete your account</button>
</div>
</div>
)}
</div>
</div>
<p className="text-zinc-500 text-sm mb-4 border-b-2">example@gmail.com</p>
</div>
<div>
<label className="text-zinc-900 font-semibold">Delete Account</label>
<p className="text-zinc-500 text-sm mb-4 border-b-2 border-gray-300">Permanently delete your tourTrek.com account</p>
</div>
</div>
</ProfileFrameElement>
);
};
</ProfileFrameElement>
);
};

export default Security;
14 changes: 7 additions & 7 deletions app/components/profileComponents/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
"use client";

import React, { useState } from 'react';

import Popup from '../elementsUi/Popup';
import Link from 'next/link';
interface SidebarProps {
setCurretScreen: (screen: string) => void;
}

const Sidebar: React.FC<SidebarProps> = ({ setCurretScreen }) => {
const [showPopup, setShowPopup] = useState(false);
const [hoveredItem, setHoveredItem] = useState<string | null>(null);
const [selectedItem, setSelectedItem] = useState<string | null>(null);
const [selectedItem, setSelectedItem] = useState<string | null>('Personal Information');

const togglePopup = () => {
setShowPopup(!showPopup);
Expand All @@ -25,7 +23,7 @@ const Sidebar: React.FC<SidebarProps> = ({ setCurretScreen }) => {
setHoveredItem(null);
};

const handleItemClick = (item: string, screen: string) => {
const handleItemClick = (item: string, screen: string) => {
setSelectedItem(item);
setCurretScreen(screen);
};
Expand Down Expand Up @@ -81,6 +79,7 @@ const Sidebar: React.FC<SidebarProps> = ({ setCurretScreen }) => {
},
];


return (
<aside className="w-64 bg-white border-r-2 border-gray-300">
<div className="text-center mb-4">
Expand All @@ -104,19 +103,20 @@ const Sidebar: React.FC<SidebarProps> = ({ setCurretScreen }) => {
<button
onMouseEnter={() => handleMouseEnter(item.name)}
onMouseLeave={handleMouseLeave}
className={`flex items-center p-2 ${selectedItem === item.name ? 'text-black bg-gray-300' : 'text-gray-400'} hover:text-black hover:bg-gray-300 font-bold text-lg w-full text-left`}
className={`flex items-center p-2 ${
(selectedItem === item.name || (selectedItem === 'Personal Information' && item.name === 'Personal information')) ? 'text-black bg-gray-300 font-bold' : 'text-gray-400'
} hover:text-black hover:bg-gray-300 text-lg w-full text-left`}
onClick={() => handleItemClick(item.name, item.screen)}
>
{item.icon}
{item.name}
</button>
</li>
))}

</ul>
</nav>
</aside>
);
};

export default Sidebar;
export default Sidebar;
24 changes: 12 additions & 12 deletions app/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

"use client";
import React, { useState } from 'react';
import Sidebar from '../components/profileComponents/Sidebar';
import Security from '../components/profile/security';
import Payments from '../components/profile/Payment';
import Preferences from '../components/profile/Preferences';
import getUserProfile from '../actions/getUserProfile';
import React, { useState } from "react";
import Sidebar from "../components/profileComponents/Sidebar";
import Security from "../components/profile/security";
import Payments from "../components/profile/Payment";
import Preferences from "../components/profile/Preferences";
import getUserProfile from "../actions/getUserProfile";
import PersonalInfo from "../components/profile/PersonalInfo"

const ProfilePage = () => {
const [currentScreen, setCurrentScreen] = useState('PersonalInfo');
const [currentScreen, setCurrentScreen] = useState("PersonalInfo");

return (
<div className="container mx-auto max-w-screen-lg flex">
<Sidebar setCurretScreen={setCurrentScreen} />
<main className="flex-grow">
{currentScreen === 'Security' && <Security />}
{currentScreen === 'Payments' && <Payments />}
{currentScreen === 'Preferences' && <Preferences />}
{currentScreen === 'PersonalInfo' && <Preferences />}
{currentScreen === "Security" && <Security />}
{currentScreen === "Payments" && <Payments />}
{currentScreen === "Preferences" && <Preferences />}
{currentScreen === "PersonalInfo" && <PersonalInfo />}
</main>
</div>
);
Expand Down
Loading

0 comments on commit 0fb810f

Please sign in to comment.