Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
Binary file added src/views/Frontend/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions src/views/Frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added src/views/Frontend/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/views/Frontend/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/views/Frontend/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions src/views/Frontend/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
26 changes: 26 additions & 0 deletions src/views/Frontend/src/components/Confirmation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// src/components/Confirmation.js
import React from 'react';

const Confirmation = ({ contentDetails, tokenDetails, onConfirm }) => {
if (!contentDetails || !tokenDetails) {
return <div>Error: Missing required props</div>;
}

return (
<div className="confirmation-container">
<h2>Confirm Content and Token Creation</h2>
<h3>Content Details:</h3>
<p>Title: {contentDetails.title}</p>
<p>Description: {contentDetails.description}</p>
<h3>Token Parameters:</h3>
<p>NFT Name: {tokenDetails.nftName}</p>
<p>NFT Symbol: {tokenDetails.nftSymbol}</p>
<p>Total Supply of DRM Tokens: {tokenDetails.totalSupply}</p>
<button className="confirm-button" onClick={onConfirm}>
Create Content and Tokens
</button>
</div>
);
};

export default Confirmation;
48 changes: 48 additions & 0 deletions src/views/Frontend/src/components/ContentDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// src/components/ContentDetail.js
import React from 'react';
import { useParams } from 'react-router-dom';

const ContentDetail = ({ contents }) => {
const { id } = useParams();
const content = contents.find(c => c.id === id);

if (!content) {
return <p>Content not found</p>;
}

let contentDisplay;
switch (content.type) {
case 'text':
contentDisplay = <p>{content.text}</p>;
break;
case 'video':
contentDisplay = (
<video width="100%" controls>
<source src={content.videoUrl} type="video/mp4" />
Your browser does not support the video tag.
</video>
);
break;
case 'photos':
contentDisplay = (
<div>
{content.photos.map((photo, index) => (
<img key={index} src={photo.url} alt={photo.alt} />
))}
</div>
);
break;
default:
contentDisplay = <p>Unknown content type</p>;
}

return (
<div>
<h2>{content.title}</h2>
<p>{content.description}</p>
{contentDisplay}
</div>
);
};

export default ContentDetail;
24 changes: 24 additions & 0 deletions src/views/Frontend/src/components/ContentList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// src/components/ContentList.js
import React from 'react';
import { Link } from 'react-router-dom';

const ContentList = ({ contents }) => {
if (!contents || contents.length === 0) {
return <p>Loading...</p>; // or display an error message
}

return (
<div>
<h2>Your Created Content</h2>
<ul>
{contents.map(content => (
<li key={content.id}>
<Link to={`/content/${content.id}`}>{content.title}</Link>
</li>
))}
</ul>
</div>
);
};

export default ContentList;
67 changes: 67 additions & 0 deletions src/views/Frontend/src/components/ContentUploadForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// src/components/ContentUploadForm.js
import React, { useState } from 'react';

const ContentUploadForm = ({ onNext }) => {
const [title, setTitle] = useState('');
const [description, setDescription] = useState('');
const [files, setFiles] = useState([]);
const [error, setError] = useState(null);

const handleFileChange = (e) => {
const files = e.target.files;
const allowedTypes = ['text/plain', 'video/mp4', 'image/jpeg', 'image/png']; // Add more types as needed
const maxSize = 10 * 1024 * 1024; // 10MB

for (const file of files) {
if (!allowedTypes.includes(file.type)) {
setError(`Invalid file type: ${file.type}`);
return;
}

if (file.size > maxSize) {
setError(`File too large: ${file.size} bytes`);
return;
}
}

setFiles(files);
};

const handleSubmit = (e) => {
e.preventDefault();

if (!title || !description) {
setError('Please fill in all fields');
return;
}

// Call API to upload content
fetch('/api/upload-content', {
method: 'POST',
body: new FormData(e.target),
})
.then((response) => response.json())
.then((data) => {
onNext();
})
.catch((error) => {
setError(`Error uploading content: ${error.message}`);
});
};

return (
<form onSubmit={handleSubmit}>
<h2>Upload Your Content</h2>
{error && <p style={{ color: 'red' }}>{error}</p>}
<label>Content Title:</label>
<input type="text" value={title} onChange={(e) => setTitle(e.target.value)} placeholder="Content Title" required />
<label>Description:</label>
<input type="text" value={description} onChange={(e) => setDescription(e.target.value)} placeholder="Content Description" required />
<label>Upload your text, video, or photo:</label>
<input type="file" multiple onChange={handleFileChange} required />
<button type="submit">Next</button>
</form>
);
};

export default ContentUploadForm;
32 changes: 32 additions & 0 deletions src/views/Frontend/src/components/Footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* src/components/Footer.css */
.footer {
background-color: #333;
color: white;
text-align: center;
padding: 20px 0;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
color: white;
text-align: center;
}

.footer-links {
list-style: none;
padding: 0;
}

.footer-links li {
display: inline;
margin: 0 10px;
}

.footer-links a {
color: white;
text-decoration: none;
}

.footer-links a:hover {
text-decoration: underline;
}
21 changes: 21 additions & 0 deletions src/views/Frontend/src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import React from 'react';
import './Footer.css'; // Optional: To include styles for the footer

const Footer = () => {
return (
<footer className="footer">
<div className="footer-content">
<p>&copy; 2024 Content Creation Page</p>
<ul className="footer-links">
<li><a href="/about">About Us</a></li>
<li><a href="/services">Services</a></li>
<li><a href="/contact">Contact</a></li>
<li><a href="/privacy-policy">Privacy Policy</a></li>
</ul>
</div>
</footer>
);
};

export default Footer;
33 changes: 33 additions & 0 deletions src/views/Frontend/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState } from 'react';
import './Navbar.css'; // Assuming you have a CSS file for styling
import Login from '../pages/Login';
import Register from '../pages/Register';

const Navbar = () => {
const [active, setActive] = useState(false);

const handleToggle = () => {
setActive(!active);
};

return (
<nav className="navbar">
<div className="navbar-brand">
<span>Content Creation Page</span>
</div>
<div className={`navbar-toggle ${active ? 'active' : ''}`} onClick={handleToggle}>
<span></span>
<span></span>
<span></span>
</div>
<div className={`navbar-menu ${active ? 'active' : ''}`}>
<ul>
<li><a href="/Login">LOGIN</a></li>
<li><a href="/Register">REGISTER</a></li>
</ul>
</div>
</nav>
);
};

export default Navbar;
58 changes: 58 additions & 0 deletions src/views/Frontend/src/components/LoginForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// src/components/LoginForm.js
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';

const LoginForm = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState(null);
const [loading, setLoading] = useState(false);
const navigate = useNavigate();

const handleSubmit = (e) => {
e.preventDefault();

if (!email || !password) {
setError('Please fill in all fields');
return;
}

setLoading(true);

// Call API for login
fetch('/api/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email, password }),
})
.then((response) => response.json())
.then((data) => {
navigate('/dashboard');
})
.catch((error) => {
setError(`Error logging in: ${error.message}`);
})
.finally(() => {
setLoading(false);
});
};

return (
<form onSubmit={handleSubmit}>
<h2>Welcome Back</h2>
{error && <p style={{ color: 'red' }}>{error}</p>}
<label>Email:</label>
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Enter your email" required />
<label>Password:</label>
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="Enter your password" required />
<button type="submit" disabled={loading}>
{loading ? 'Logging in...' : 'Login'}
</button>
<p>Don't have an account? <a href="/register">Register now</a></p>
</form>
);
};

export default LoginForm;
Loading