Skip to content

Commit

Permalink
Merge pull request #80 from adityalaxkar123/main
Browse files Browse the repository at this point in the history
added loan section
  • Loading branch information
skmirajulislam authored Oct 6, 2024
2 parents 9d935e6 + 884c7e0 commit 6aca50f
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 14 deletions.
3 changes: 3 additions & 0 deletions frontend/package-lock.json

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

11 changes: 8 additions & 3 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from "react";

import { Routes, Route } from "react-router-dom";

This comment has been minimized.

Copy link
@ArchanRD

ArchanRD Oct 6, 2024

Contributor

The re-import of Routes and Route is breaking application throwing an error. Please remove the redeclaration.


import { Routes, Route, useLocation } from "react-router-dom"; // Resolved spacing issue

import Navbar from "./components/Navbar/Navbar.js";
import Hom from "./pages/Home/Hom.js";
import Educ from "./components/Education/Educ.js";
Expand All @@ -11,7 +15,7 @@ import Login from "./components/Login/Login.js";
import Signup from "./components/Signup/Signup.js";
import Footer from "./components/Footer/Footer.js";
import About from "./pages/About/About.js";

import Loan from "./pages/Loan/Loan.js"; // Ensure the path is correct
function App() {
const location = useLocation();
return (
Expand All @@ -21,14 +25,15 @@ function App() {
<main>
<Routes>
<Route path="/" element={<Hom />} />
<Route path="/loan" element={<Loan />} /> {/* Corrected this line */}
<Route path="/about" element={<About />} />
<Route path="/educ" element={<Educ />} />
<Route path="/sef" element={<Sef />} />
<Route path="/craft" element={<Craft />} />
<Route path="/quiz" element={<Quiz />} />
<Route path="/act" element={<Act />} />
<Route path="/login" element={<Login/>}/>
<Route path="/Signup" element={<Signup />} />
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<Signup />} /> {/* Use lowercase for consistency */}
</Routes>
</main>
{location.pathname !== "/login" && location.pathname.toLowerCase() !== "/signup" && <Footer />} </div>
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/components/Loan/Loan.js

This file was deleted.

9 changes: 9 additions & 0 deletions frontend/src/components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ function Navbar() {
<li><a href="/contact">Contact Us</a></li>
</ul>
</div>

<ul className="nav-links desktop-links">
<li><a href="/">Home</a></li>
<li><a href="/about">About Us</a></li>
<li><a href="/contact">Contact Us</a></li>
<li><a href="/loan">Loan</a></li>
</ul>


<div className={`nav-menu ${isActive ? 'active' : ''}`}>
<button className="close-button" onClick={closeNavbar}>
&times; {/* Close icon */}
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/Home/Hom.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ export default function Hom() {
<div className="card-content">
<img src={item.image} alt={item.title} className="card-image" />
<p className="card-description">{item.description}</p>
<button className="btn-default card-button">{item.action}</button>
{item.title === "Loans and Grants" && (
<Link to="/Loan"><button className="btn-default card-button">{item.action}</button></Link>
)}

{item.title !== "Loans and Grants" && (
<button className="btn-default card-button">{item.action}</button>
)}
</div>
</div>
))}
Expand Down
166 changes: 166 additions & 0 deletions frontend/src/pages/Loan/Loan.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/* LoanPage.css */

.loan-container {
max-width: 900px;
margin: 0 auto;
padding: 20px; /* Reduced padding for smaller devices */
background-color: #f8f9fa;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.loan-title {
font-size: 2rem; /* Adjusted for smaller screens */
margin-bottom: 30px; /* Reduced space below the title */
color: #2B4B77;
text-align: center;
text-transform: uppercase;
letter-spacing: 1px;
}

.horizontal-cards {
display: flex;
justify-content: space-between;
margin-bottom: 30px; /* Reduced space below the horizontal cards */
flex-wrap: wrap; /* Allow wrapping to next line if necessary */
}

.loan-section {
background-color: #ffffff;
border-radius: 8px;
padding: 20px;
margin: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
transition: transform 0.2s;
flex: 1 1 30%; /* Adjust card size and allow wrapping */
min-width: 260px; /* Minimum width for smaller screens */
}

.loan-section:hover {
transform: translateY(-5px);
}

.loan-section h2 {
font-size: 1.5rem; /* Adjusted for smaller screens */
color: #2B4B77;
margin-bottom: 10px;
}

.loan-section p {
font-size: 0.9rem; /* Adjusted for smaller screens */
margin-bottom: 10px;
line-height: 1.5; /* Better readability */
}

.loan-types-container {
display: flex;
justify-content: space-between;
margin: 20px 0;
}

.loan-type {
background-color: #ffffff;
border-radius: 8px;
padding: 15px;
flex: 1;
margin: 0 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
text-align: center;
}

.loan-button {
background-color: #2B4B77;
color: white;
border: none;
border-radius: 5px;
padding: 10px 15px; /* Adjusted for smaller screens */
font-size: 0.9rem; /* Adjusted for smaller screens */
cursor: pointer;
transition: background-color 0.3s, transform 0.2s;
display: inline-block;
text-decoration: none;
margin-top: 10px;
}

.loan-button:hover {
background-color: #1f3d5b;
transform: scale(1.05);
}

.tips {
margin-top: 20px;
}

.loan-calculator {
margin-top: 40px;
background-color: #ffffff;
border-radius: 8px;
padding: 25px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.calculator-form {
display: flex;
flex-direction: column; /* Stack inputs vertically */
}

.calculator-form label {
margin-bottom: 15px;
font-size: 1rem;
}

.calculator-form input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}

.calculator-result {
margin-top: 20px;
font-size: 1.5rem;
color: #2B4B77;
}

/* Media Queries for Responsiveness */
@media (max-width: 768px) {
.loan-title {
font-size: 1.8rem; /* Smaller title for tablets and phones */
}

.horizontal-cards {
flex-direction: column; /* Stack cards vertically */
}

.loan-section {
flex: 1 1 100%; /* Full width on small screens */
margin-bottom: 20px; /* Space between stacked cards */
}

.loan-button {
padding: 10px; /* Smaller button padding */
font-size: 0.85rem; /* Smaller button font size */
}

.calculator-form input {
font-size: 0.9rem; /* Smaller input font size */
}
}

@media (max-width: 480px) {
.loan-title {
font-size: 1.6rem; /* Smaller title for phones */
}

.loan-section h2 {
font-size: 1.4rem; /* Smaller heading for cards */
}

.loan-section p {
font-size: 0.85rem; /* Smaller paragraph font size */
}

.calculator-result {
font-size: 1.2rem; /* Smaller result font size */
}
}
111 changes: 111 additions & 0 deletions frontend/src/pages/Loan/Loan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// src/LoanPage.js
import React, { useState } from 'react';
import './Loan.css'; // Import your custom CSS file

const Loan = () => {
const [loanAmount, setLoanAmount] = useState('');
const [interestRate, setInterestRate] = useState('');
const [loanTerm, setLoanTerm] = useState('');
const [totalPayment, setTotalPayment] = useState(null);

const calculateTotalPayment = () => {
const principal = parseFloat(loanAmount);
const calculatedInterest = (principal * (parseFloat(interestRate) / 100)) * parseFloat(loanTerm);
const total = principal + calculatedInterest;
setTotalPayment(total.toFixed(2));
};

return (
<div className="loan-container">
<h1 className="loan-title">Understanding Loans and Grants</h1>

<div className="horizontal-cards">
<section className="loan-section">
<h2>What is a Loan?</h2>
<p>
A loan is a sum of money that is borrowed and is expected to be paid back with interest.
Loans can be secured (backed by collateral) or unsecured (not backed by collateral).
</p>
<a href="https://en.wikipedia.org/wiki/Loan" target="_blank" rel="noopener noreferrer">
<button className="loan-button">Learn More</button>
</a>
</section>

<section className="loan-section">
<h2>What is a Grant?</h2>
<p>
A grant is a financial award given by a government agency, organization, or individual for a specific purpose,
and it does not need to be paid back.
</p>
<a href="https://en.wikipedia.org/wiki/Grant_(law)" target='_blank' rel="noopener noreferrer">
<button className="loan-button">Learn More</button>
</a>
</section>

<section className="loan-section types-of-loans">
<h2>Types of Loans</h2>
<ul>
<li>Personal Loans</li>
<li>Student Loans</li>
<li>Mortgage Loans</li>
<li>Auto Loans</li>
</ul>
<a href="https://en.wikipedia.org/wiki/Loan#Types" target='_blank' rel="noopener noreferrer">
<button className="loan-button">View Details</button>
</a>
</section>
</div>

<section className="loan-section tips">
<h2>Tips for Applying for Loans and Grants</h2>
<ul>
<li>Check your credit score before applying.</li>
<li>Research various options to find the best terms.</li>
<li>Gather necessary documentation in advance.</li>
<li>Be clear about your purpose and how you plan to use the funds.</li>
</ul>
</section>

<section className="loan-calculator">
<h2>Loan Calculator</h2>
<div className="calculator-form">
<label>
Loan Amount:
<input
type="number"
value={loanAmount}
onChange={(e) => setLoanAmount(e.target.value)}
placeholder="Enter amount"
/>
</label>
<label>
Interest Rate (%):
<input
type="number"
value={interestRate}
onChange={(e) => setInterestRate(e.target.value)}
placeholder="Enter rate"
/>
</label>
<label>
Loan Term (years):
<input
type="number"
value={loanTerm}
onChange={(e) => setLoanTerm(e.target.value)}
placeholder="Enter term"
/>
</label>
<button onClick={calculateTotalPayment} className="loan-button">Calculate</button>
</div>
{totalPayment && (
<div className="calculator-result">
<h3>Total Amount to be Paid: ${totalPayment}</h3>
</div>
)}
</section>
</div>
);
};

export default Loan;

0 comments on commit 6aca50f

Please sign in to comment.