FSWD 5th Program
FSWD 5th Program
EX:5-SELLING APP
App.js
function App() {
return (
<Router>
<Navbar />
<Routes>
</Routes>
</Router>
);
Style.css
.App {
text-align: center;
/* Global Styles */
body {
margin: 0;
padding: 0;
background-color: #f4f4f4;
/* Navbar Styles */
nav {
background-color: #333;
color: #fff;
padding: 1rem;
nav h1 {
display: inline;
margin-right: 2rem;
nav ul {
list-style: none;
padding: 0;
}
nav ul li {
display: inline;
margin-right: 1rem;
nav a {
color: #360ee6;
text-decoration: none;
nav a:hover {
text-decoration: underline;
h2 {
color: #333;
margin: 2rem 0;
}
/* Listing Styles */
ul {
list-style-type: none;
padding: 0;
li {
background: white;
margin: 1rem 0;
padding: 1rem;
border-radius: 5px;
button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
button:hover {
background-color: #0056b3;
/* Form Styles */
form {
background: white;
padding: 1.5rem;
border-radius: 5px;
margin: 2rem 0;
width: 100%;
padding: 0.5rem;
margin: 0.5rem 0;
#ccc; border-radius:
5px;
form button {
width: 100%;
p {
margin: 0.5rem 0;
.error {
color: red;
.success {
color: green;
}
li {
background: white;
margin: 1rem 0;
padding: 1rem;
border-radius: 5px;
display: flex;
li img {
*/
}
Index.js
import './styles.css';
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
Components–Home.js
import React from 'react';
Components–Navbar.js
Components–Auth–Login.js
import React, { useState } from 'react';
import axios from 'axios';
return (
<div>
<h2>Login</h2>
{error && <p style={{ color: 'red' }}>{error}</p>}
<form onSubmit={handleSubmit}>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Email"
required
/>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="Password"
required
/>
<button type="submit">Login</button>
</form>
</div>
);
};
Components–Auth–Register.js
import React, { useState } from 'react';
import axios from 'axios';
return (
<div>
<h2>Register</h2>
{error && <p style={{ color: 'red' }}>{error}</p>}
{success && <p style={{ color: 'green' }}>{success}</p>}
<form onSubmit={handleSubmit}>
<input
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Username"
required
/>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Email"
required
/>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="Password"
required
/>
<button type="submit">Register</button>
</form>
</div>
);
};
Components–Listings–ListingForm.js
import React, { useState } from 'react';
return (
<form onSubmit={handleSubmit}>
<input
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="Title"
required
/>
<textarea
value={description}
onChange={(e) => setDescription(e.target.value)}
placeholder="Description"
required
/>
<input
type="number"
value={price}
onChange={(e) => setPrice(e.target.value)}
placeholder="Price"
required
/>
<button type="submit">Create Listing</button>
</form>
);
};
Components–Listings–ListingList.js
import React from 'react';
import ListingItem from './ListingItem';
return (
<div>
<h2>Listings</h2>
<ul>
{listings.map((listing) => (
<ListingItem key={listing.id} listing={listing} />
))}
</ul>
</div>
);
};