First #1

Open
mihir_dml wants to merge 1 commit from Devlopment into main
Owner
No description provided.
mihir_dml added 1 commit 2025-01-03 05:30:13 +00:00
mihir_dml requested review from sumitdml123 2025-01-03 05:30:21 +00:00
mihir_dml requested review from mayank.sethi 2025-01-03 05:30:21 +00:00
sumitdml123 requested changes 2025-01-03 12:26:21 +00:00
@ -0,0 +13,4 @@
<h1>Random Users</h1>
<p>Explore a diverse set of random users from all over the world!</p>
<div className="hero-section">
<button onClick={() => window.location.href = '/home'}>View Users</button>
Collaborator

You're using window.location.href for navigation in the button click event. It's better to use the useNavigate hook from react-router-dom for navigation within a React app. This ensures that the navigation is handled by React's routing system, preventing a full page reload.

You're using window.location.href for navigation in the button click event. It's better to use the useNavigate hook from react-router-dom for navigation within a React app. This ensures that the navigation is handled by React's routing system, preventing a full page reload.
@ -0,0 +20,4 @@
// Fetch data from the API
useEffect(() => {
fetch('https://randomuser.me/api/?results=200')
Collaborator

error handling is missing from the function use try catch

error handling is missing from the function use try catch
@ -0,0 +51,4 @@
if (selectedAgeRange) {
const [minAge, maxAge] = selectedAgeRange.split('-').map(Number);
filtered = filtered.filter(user => {
const userAge = new Date().getFullYear() - new Date(user.dob.date).getFullYear();
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +64,4 @@
// Sorting logic
if (sortBy === 'name') {
filtered = filtered.sort((a, b) => {
const nameA = `${a.name.first} ${a.name.last}`.toLowerCase();
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +67,4 @@
const nameA = `${a.name.first} ${a.name.last}`.toLowerCase();
const nameB = `${b.name.first} ${b.name.last}`.toLowerCase();
if (sortOrder === 'asc') {
return nameA.localeCompare(nameB);
Collaborator

naming convention is not right use proper variable names

naming convention is not right use proper variable names
@ -0,0 +90,4 @@
// Pagination logic
const indexOfLastUser = currentPage * usersPerPage;
const currentUsers = filteredData.slice(indexOfLastUser - usersPerPage, indexOfLastUser);
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +99,4 @@
for (let i = 1; i <= totalPages; i++) {
if (i <= 2 || i > totalPages - 2 || (i >= currentPage - maxPageRange && i <= currentPage + maxPageRange)) {
pageNumbers.push(i);
} else if (pageNumbers[pageNumbers.length - 1] !== '...') {
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +107,4 @@
// Function to handle clicking on More Info
const handleMoreInfo = (user) => {
setUserDetail(user);
navigate(`/user-details`);
Collaborator

You're using const [setUserDetail] = useState(null);, but setUserDetail is not required as a state. Instead, you can directly navigate with the user details using state in useNavigate.

try this and check if it works
const handleMoreInfo = (user) => {
navigate(/user-details, { state: { user } });
};

And in the UserDetails component, you can access this user via location.state.user.

You're using const [setUserDetail] = useState(null);, but setUserDetail is not required as a state. Instead, you can directly navigate with the user details using state in useNavigate. try this and check if it works const handleMoreInfo = (user) => { navigate(`/user-details`, { state: { user } }); }; And in the UserDetails component, you can access this user via location.state.user.
@ -0,0 +138,4 @@
{filteredData.length > 0 ? (
<>
<div className="user-grid">
{currentUsers.map(user => (
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +14,4 @@
<div className="user-card" key={user.email}>
<img src={user.picture.medium} alt={user.name.first} />
<div className="user-info">
<h3>{user.name.first} {user.name.last}</h3>
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +17,4 @@
const userData = [
['First Name', 'Last Name', 'Email', 'Phone', 'Cell', 'Address', 'Date of Birth', 'Nationality', 'Timezone', 'Coordinates', 'Username'],
[
user.name.first,
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +23,4 @@
user.phone,
user.cell,
`${user.location.street.number} ${user.location.street.name}, ${user.location.city}, ${user.location.state}, ${user.location.country} - ${user.location.postcode}`,
new Date(user.dob.date).toLocaleDateString(),
Collaborator

toLocaleDateString('en-US') use like this

toLocaleDateString('en-US') use like this
@ -0,0 +26,4 @@
new Date(user.dob.date).toLocaleDateString(),
user.nat,
user.location.timezone.description,
`${user.location.coordinates.latitude}, ${user.location.coordinates.longitude}`,
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +41,4 @@
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', `${user.name.first}_${user.name.last}_details.csv`);
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +52,4 @@
return (
<div className="user-details">
<h2>{user.name.first} {user.name.last}</h2>
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +57,4 @@
{/* Display user details */}
<div className="user-info">
<div><strong>Email:</strong> {user.email}</div>
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +61,4 @@
<div><strong>Phone:</strong> {user.phone}</div>
<div><strong>Cell:</strong> {user.cell}</div>
<div>
<strong>Location:</strong> {user.location.street.number} {user.location.street.name}, {user.location.city}, {user.location.state}, {user.location.country} - {user.location.postcode}
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +63,4 @@
<div>
<strong>Location:</strong> {user.location.street.number} {user.location.street.name}, {user.location.city}, {user.location.state}, {user.location.country} - {user.location.postcode}
</div>
<div><strong>Date of Birth:</strong> {new Date(user.dob.date).toLocaleDateString()}</div>
Collaborator

toLocaleDateString('en-US') use this

toLocaleDateString('en-US') use this
@ -0,0 +67,4 @@
<div><strong>Nationality:</strong> {user.nat}</div>
<div><strong>Timezone:</strong> {user.location.timezone.description}</div>
<div>
<strong>Coordinates:</strong> {user.location.coordinates.latitude}, {user.location.coordinates.longitude}
Collaborator

optional chaining is missing

optional chaining is missing
@ -0,0 +69,4 @@
<div>
<strong>Coordinates:</strong> {user.location.coordinates.latitude}, {user.location.coordinates.longitude}
</div>
<div><strong>Username:</strong> {user.login.username}</div>
Collaborator

optional chaining is missing

optional chaining is missing
This pull request has changes conflicting with the target branch.
  • src/App.css
  • src/App.js
  • src/Home.js
  • src/SearchFilter.js
  • src/UserCard.js
  • src/UserDetail.js
  • src/index.css
  • src/index.js

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin Devlopment:Devlopment
git checkout Devlopment

Merge

Merge the changes and update on Forgejo.
git checkout main
git merge --no-ff Devlopment
git checkout main
git merge --ff-only Devlopment
git checkout Devlopment
git rebase main
git checkout main
git merge --no-ff Devlopment
git checkout main
git merge --squash Devlopment
git checkout main
git merge --ff-only Devlopment
git checkout main
git merge Devlopment
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mihir_dml/Assigment4#1
No description provided.