Skip to content

Commit

Permalink
modals created
Browse files Browse the repository at this point in the history
  • Loading branch information
mdauwal committed Oct 13, 2024
1 parent be51789 commit 739ee55
Show file tree
Hide file tree
Showing 15 changed files with 394 additions and 68 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@fortawesome/fontawesome-svg-core": "^6.6.0",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@fortawesome/react-fontawesome": "^0.2.2",
"@headlessui/react": "^2.1.9",
"@headlessui/react": "^2.1.10",
"@heroicons/react": "^2.1.5",
"@mui/icons-material": "^6.1.2",
"@react-spring/web": "^9.7.5",
Expand Down
Empty file removed src/appLayout/MainNavigation.css
Empty file.
Empty file removed src/appLayout/MainNavigation.jsx
Empty file.
57 changes: 57 additions & 0 deletions src/appLayout/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Bars3Icon, BellIcon, ChevronDownIcon } from "@heroicons/react/24/outline";
import { Link } from "react-router-dom";
import { Menu } from "@headlessui/react"; // Import from Headless UI
import logo from "../assets/logo.png";
import profile from "../assets/profile.png";

const Navbar = ({ onSidebarToggle }) => {
const userNavigation = [
{ name: "Profile", href: "#" },
{ name: "Settings", href: "#" },
{ name: "Log out", href: "/login" },
];

return (
<header className="bg-white border-b border-gray-200">
<div className="flex justify-between items-center px-4 py-4">
<div className="flex items-center">
<button onClick={onSidebarToggle} className="lg:hidden">
<Bars3Icon className="h-6 w-6" />
</button>
<img src={logo} alt="Logo" className="h-8 w-auto ml-4" />
</div>
<div className="flex items-center gap-4">
<button>
<BellIcon className="h-6 w-6 text-gray-500" />
</button>
<Menu as="div" className="relative">
<div>
<Menu.Button className="flex items-center space-x-2">
<img src={profile} alt="Profile" className="h-8 w-8 rounded-full" />
<ChevronDownIcon className="h-5 w-5 text-gray-500" />
</Menu.Button>
</div>
<Menu.Items className="absolute right-0 mt-2 w-48 bg-white shadow-lg">
{userNavigation.map((item) => (
<Menu.Item key={item.name}>
{({ active }) => (
<Link
to={item.href}
className={`block px-4 py-2 text-gray-700 ${
active ? "bg-gray-100" : ""
}`}
>
{item.name}
</Link>
)}
</Menu.Item>
))}
</Menu.Items>
</Menu>
</div>
</div>
</header>
);
};

export default Navbar;
58 changes: 58 additions & 0 deletions src/appLayout/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// // Sidebar.jsx
// import { Link } from "react-router-dom";
// import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline";
// import { useState } from "react";
// import logo from "../assets/logo.png";
// import { navigation } from "../pages/navigationData"; // Externalized navigation data

// const Sidebar = ({ isOpen }) => {
// const [openDropdown, setOpenDropdown] = useState(null);

// const toggleDropdown = (name) => {
// setOpenDropdown(openDropdown === name ? null : name);
// };

// return (
// <div className={`lg:flex ${isOpen ? "block" : "hidden"} w-72 bg-white`}>
// <div className="flex flex-col h-screen border-r border-gray-200 px-6">
// <div className="flex items-center h-16">
// <img src={logo} alt="Logo" className="h-8 w-auto" />
// </div>
// <nav className="flex-1 overflow-y-auto">
// <ul className="space-y-7">
// {navigation.map((item) => (
// <li key={item.name}>
// <Link to={item.href} className="flex items-center gap-x-3 p-2 rounded-md hover:bg-gray-100">
// <img src={item.icon} alt={item.name} className="h-6 w-6" />
// <span>{item.name}</span>
// {item.hasDropdown && (
// <button onClick={() => toggleDropdown(item.name)}>
// {openDropdown === item.name ? (
// <ChevronUpIcon className="w-5 h-5" />
// ) : (
// <ChevronDownIcon className="w-5 h-5" />
// )}
// </button>
// )}
// </Link>
// {item.hasDropdown && openDropdown === item.name && (
// <ul className="ml-8 mt-2 space-y-1">
// {item.children.map((subItem) => (
// <li key={subItem.name}>
// <Link to={subItem.href} className="block p-2 hover:bg-gray-100">
// {subItem.name}
// </Link>
// </li>
// ))}
// </ul>
// )}
// </li>
// ))}
// </ul>
// </nav>
// </div>
// </div>
// );
// };

// export default Sidebar;
86 changes: 65 additions & 21 deletions src/pages/ActivityTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const ActivityTab = () => {
const [newStatus, setNewStatus] = useState('All');
const [filteredActivity, setFilteredActivity] = useState(activityData);

const [isAddingComment, setIsAddingComment] = useState(false); // To control comment section display
const [newComment, setNewComment] = useState(''); // To store the new comment

// Function to filter activities based on search criteria
const handleSearch = () => {
const filtered = activityData.filter((activity) => {
Expand All @@ -35,8 +38,21 @@ const ActivityTab = () => {
setFilteredActivity(filtered);
};

// Function to handle the new comment submission
const handleAddComment = () => {
const newActivity = {
date: new Date().toLocaleString(),
actionBy: 'User', // Example: Comment will be added by the user
status: 'COMMENT ADDED',
message: newComment
};
setFilteredActivity([newActivity, ...filteredActivity]);
setNewComment('');
setIsAddingComment(false); // Hide the comment section after submission
};

return (
<div className="activity-tab text-[#4A5D58]">
<div className="activity-tab text-sm text-[#4A5D58]">
{/* Search Section */}
<div className="flex flex-wrap gap-4 mb-5">
<div className="flex flex-col">
Expand Down Expand Up @@ -80,7 +96,6 @@ const ActivityTab = () => {
<option value="DECLINED">Declined</option>
</select>
</div>


<div className="flex items-end">
<button
Expand All @@ -91,31 +106,60 @@ const ActivityTab = () => {
</button>
</div>
</div>

{/* Add Comment Section */}
<div className="mb-5">
<h1 className='mb-4'>View Rule Breakdown</h1>
<button className="bg-white border-solid border-2 border-[#4A5D58] px-8 py-2 rounded-md">Add Comment</button>
<h1 className="mb-4">View Rule Breakdown</h1>
{!isAddingComment ? (
<button
onClick={() => setIsAddingComment(true)}
className="bg-white border-solid border-2 border-[#4A5D58] px-8 py-2 rounded-md"
>
Add Comment
</button>
) : (
<div className="flex flex-col space-y-3">
<textarea
className="border border-gray-300 p-3 resize-none rounded-md focus:outline-none focus:ring-2 focus:ring-[#00C795]"
placeholder="Enter your comment..."
value={newComment}
onChange={(e) => setNewComment(e.target.value)}
/>
<div className="flex space-x-3">
<button
onClick={handleAddComment}
className="bg-[#00C795] text-white px-4 py-2 rounded-md"
>
Submit Comment
</button>
<button
onClick={() => setIsAddingComment(false)}
className="bg-gray-200 px-4 py-2 rounded-md"
>
Cancel
</button>
</div>
</div>
)}
</div>

{/* Activity List */}
<div className="activity-list space-y-4">
{filteredActivity.length > 0 ? (
filteredActivity.slice(0, 4).map((activity, index) => ( // Limit to 4 comments
<div key={index} className="border-b py-4">
<div className="flex flex-col sm:flex-row justify-between">
<div className="text-sm text-gray-600">{activity.message}</div>
</div>
<div className="text-sm text-gray-500 mt-1"> {/* Add margin-top for spacing */}
Date: {activity.date} | Action by: {activity.actionBy} | Status: {activity.status}
</div>
<div className="activity-list space-y-4">
{filteredActivity.length > 0 ? (
filteredActivity.slice(0, 4).map((activity, index) => ( // Limit to 4 comments
<div key={index} className="border-b py-4">
<div className="flex flex-col sm:flex-row justify-between">
<div className="text-sm text-gray-600">{activity.message}</div>
</div>
<div className="text-sm text-gray-500 mt-1">
Date: {activity.date} | Action by: {activity.actionBy} | Status: {activity.status}
</div>
</div>
))
) : (
<p className="text-gray-500">No matching records found.</p>
)}
</div>
))
) : (
<p className="text-gray-500">No matching records found.</p>
)}
</div>

</div>
);
};
Expand Down
26 changes: 19 additions & 7 deletions src/pages/CustomerDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import setupIcon from "../assets/setupIcon.png";
import LoanDetailsTab from "./LoanDetailsTab";
import { loanData } from "./data";
import DeclineModal from "./DeclineModal";
import UploadModal from "./UploadModal";
import { Link } from "react-router-dom";

const navigation = [
Expand Down Expand Up @@ -141,7 +142,9 @@ function classNames(...classes) {
}

export default function CustomerDetails() {
const [isModalOpen, setIsModalOpen] = useState(false); // Fixed typo in modal state
const [isModalOpen, setIsModalOpen] = useState(false)
const [isDeclineModalOpen, setIsDeclineModalOpen] = useState(false);
const [isCompleteReviewModalOpen, setIsCompleteReviewModalOpen] = useState(false);
const [searchTerm, setSearchTerm] = useState(""); // State for search input
const [activeTab, setActiveTab] = useState("Information"); // Default to 'Information' tab
const [filteredData, setFilteredData] = useState(loanData); // State for filtered data
Expand Down Expand Up @@ -179,13 +182,20 @@ export default function CustomerDetails() {
setIsModalOpen(false);
};

const handleDeclineLoan = () => {
openModal(); // Open modal when decline is clicked
// Modal handling functions
const handleDeclineLoan = () => {
setIsDeclineModalOpen(true); // Open Decline modal
};

const handleCompleteReview = () => {
console.log("Review Completed");
setIsCompleteReviewModalOpen(true); // Open Complete Review modal
};
const handleCloseDeclineModal = () => {
setIsDeclineModalOpen(false); // Close Decline modal
};
const handleCloseCompleteReviewModal = () => {
setIsCompleteReviewModalOpen(false); // Close Complete Review modal
};


return (
<>
Expand Down Expand Up @@ -474,8 +484,7 @@ export default function CustomerDetails() {
<LoanDetailsTab details={loanData[activeTab]} />
</div>

{/* Modal for Declining Loan */}
<DeclineModal isOpen={isModalOpen} closeModal={closeModal} />

</div>
{/* Decline Loan and Complete Review Buttons */}
<div className="mt-5 mr-0 sm:mr-10 flex flex-col sm:flex-row justify-end mb-10 p-1 space-y-3 sm:space-y-0 sm:space-x-3">
Expand All @@ -492,6 +501,9 @@ export default function CustomerDetails() {
Complete Review
</button>
</div>
{/* Render the modals conditionally */}
<DeclineModal isOpen={isDeclineModalOpen} closeModal={handleCloseDeclineModal} />
<UploadModal isOpen={isCompleteReviewModalOpen} closeModal={handleCloseCompleteReviewModal} />

{/* Help Widget Ends */}
</div>
Expand Down
Loading

0 comments on commit 739ee55

Please sign in to comment.