Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit e61baf9

Browse files
filter out "Enterprise" documents and add mock favorites in profile and home components
1 parent ce5c0c5 commit e61baf9

4 files changed

Lines changed: 33 additions & 23 deletions

File tree

src/frontend/components/layout/LeftSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const LeftSidebar: React.FC = () => {
116116

117117
// Simulate recent documents by sorting all documents by a "last viewed" algorithm
118118
// In a real app, this would come from user's view history
119-
const recentDocs = allDocuments
119+
const recentDocs = allDocuments.filter((a => a.id !== "mock-file-react-for-beginners" && !a.title.includes("Enterprise")))
120120
.map(doc => {
121121
// Create a simulated "last viewed" timestamp based on document properties
122122
// Use document ID and current user ID to create consistent but varied timestamps

src/frontend/components/pages/Home.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { cn } from '../../lib/utils';
1212
import DocumentView from '../modals/DocumentView';
1313
import { useAppNavigate, useScrollToTop } from '@/lib/navigation';
1414
import { Separator } from '../ui/separator';
15+
import {faker} from "@faker-js/faker";
1516

1617
const Home = () => {
1718
const appNavigate = useAppNavigate();
@@ -115,12 +116,16 @@ const Home = () => {
115116
const currentUsername = "bartsimpson"; // This would be dynamic in a real app
116117

117118
// Sort for recent (by "last opened" rather than upload date)
118-
const recentDocuments = [...allDocuments].sort((a, b) =>
119+
const recentDocuments = [...allDocuments]
120+
.filter((a => a.id !== "mock-file-react-for-beginners" && !a.title.includes("Enterprise"))) // Exclude specific document
121+
.sort((a, b) =>
119122
getHoursSinceLastOpened(a) - getHoursSinceLastOpened(b)
120123
);
121124

122125
// Sort for trending (by view count, download count, and recency)
123-
const trendingDocuments = [...allDocuments].sort((a, b) => {
126+
const trendingDocuments = [...allDocuments]
127+
.filter((a => a.id !== "mock-file-react-for-beginners" && !a.title.includes("Enterprise"))) // Exclude specific document
128+
.sort((a, b) => {
124129
// Score = (viewCount * 1) + (downloadCount * 2) + (recency factor * 4)
125130
// Recency factor = 1 / (days old + 1) to keep it between 0-1
126131
const daysA = Math.floor((new Date().getTime() - a.file.uploadedAt.getTime()) / (1000 * 60 * 60 * 24));
@@ -136,12 +141,14 @@ const Home = () => {
136141

137142
// Simple recommendations (just use a different slice of trending documents)
138143
const recommendationDocuments = [...trendingDocuments]
144+
.filter((a => a.id !== "mock-file-react-for-beginners" && !a.title.includes("Enterprise"))) // Exclude "Enterprise" documents)) // Exclude specific document
139145
.filter(doc => doc.author.username !== currentUsername) // Exclude user's own documents
140146
.slice(3, 13);
141147

142148
// Initialize favorites (mock some documents similar to Profile.tsx)
143-
const favorites = allDocuments.slice(0, 3);
144-
149+
const favorites = [...allDocuments.slice(0, 3), ...allDocuments.filter(a => a.id === "mock-file-react-for-beginners")];
150+
151+
145152
// Get user documents and sort by last edited time (newest first)
146153
const userDocuments = allDocuments
147154
.filter(doc => doc.author.username === currentUsername)
@@ -167,14 +174,14 @@ const Home = () => {
167174
if (docExists) {
168175
return prev.filter(doc => doc.id !== docId);
169176
}
170-
171-
const docToAdd = [...recentDocs, ...trendingDocs].find(doc => doc.id === docId);
177+
178+
const docToAdd = [...trendingDocs, ...recentDocs].find(doc => doc.id === docId);
172179
if (docToAdd) {
173180
return [...prev, docToAdd];
174181
}
175182
return prev;
176183
});
177-
}, [recentDocs, trendingDocs]);
184+
}, [trendingDocs, recentDocs]);
178185

179186
// Format file size
180187
const formatFileSize = (size: string): string => {

src/frontend/components/pages/Profile.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ const Profile = () => {
137137
setUserDocuments(userDocs);
138138

139139
// Sort for recent (by "last opened" rather than upload date) - same as Home
140-
const recentDocuments = [...allDocuments].sort((a, b) =>
140+
const recentDocuments = [...allDocuments]
141+
.filter(doc => !doc.title.includes("Enterprise")) // Exclude "Enterprise" documents
142+
.sort((a, b) =>
141143
getHoursSinceLastOpened(a) - getHoursSinceLastOpened(b)
142144
);
143145
setRecentDocs(recentDocuments);
144146

145147
// Mock favorites (in a real app, this would come from user data)
146-
const favorites = allDocuments.slice(0, 3);
148+
const favorites = [...allDocuments.slice(0, 3), ...allDocuments.filter(a => a.id === "mock-file-react-for-beginners")];
147149
setFavoriteDocuments(favorites);
148150

149151
// Initialize current user state if not already set

src/frontend/lib/mocking/mockedData.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ class MockDataStore {
100100
'Il Principe di Machiavelli: Politica di Potere Ieri e Oggi',
101101
'Don Chisciotte: Cervantes e la Nascita del Romanzo Moderno',
102102
'Beowulf: L\'Epica Inglese più Antica',
103-
'Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions'
103+
'Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions',
104+
'React per Principianti: Guida Completa allo Sviluppo di Interfacce Utente',
104105
];
105106

106107
const documentDescriptions = [
@@ -116,7 +117,8 @@ class MockDataStore {
116117
'Esaminando il controverso trattato politico di Niccolò Machiavelli sul potere e il governo.',
117118
'Uno studio approfondito del romanzo rivoluzionario di Miguel de Cervantes e il suo posto nella tradizione letteraria europea.',
118119
'Un\'analisi approfondita del poema epico eroico inglese antico Beowulf e il suo significato culturale.',
119-
'This is a book about enterprise integration using messaging. It does not document any particular technology or product. Rather, it is designed for developers and integrators using a variety of messaging products and technologies, such as ActiveMQ, IBM MQ, JMS, and others.'
120+
'This is a book about enterprise integration using messaging. It does not document any particular technology or product. Rather, it is designed for developers and integrators using a variety of messaging products and technologies, such as ActiveMQ, IBM MQ, JMS, and others.',
121+
'Una guida completa per principianti su React, coprendo i concetti fondamentali, le migliori pratiche e lo sviluppo di interfacce utente moderne.'
120122
];
121123

122124
const tagsPool = [
@@ -132,16 +134,17 @@ class MockDataStore {
132134
['machiavelli', 'politica', 'rinascimento'],
133135
['spagnolo', 'letteratura', 'rinascimento', 'cervantes'],
134136
['medievale', 'inglese-antico', 'epico', 'poesia'],
135-
['java', 'enterprise', 'integration', 'messaging', 'jms', 'activemq', 'ibm', 'mq']
137+
['java', 'enterprise', 'integration', 'messaging', 'jms', 'activemq', 'ibm', 'mq'],
138+
['javascript', 'react', 'frontend', 'ui', 'web']
136139
];
137140

138141
const fileTypes: ('pdf' | 'word' | 'powerpoint' | 'txt' | 'epub')[] = [
139142
'pdf', 'epub', 'pdf', 'pdf', 'epub', 'pdf',
140143
'pdf', 'epub', 'pdf', 'pdf', 'epub', 'pdf',
141-
'pdf'
144+
'pdf', "pdf"
142145
];
143146

144-
for (let i = 0; i < 13; i++) {
147+
for (let i = 0; i < 14; i++) {
145148
const userIndex = i % this.users.length;
146149
const author = this.users[userIndex];
147150

@@ -155,7 +158,7 @@ class MockDataStore {
155158

156159
// Create the file first
157160
const file: MockFile = {
158-
id: faker.string.uuid(),
161+
id: i != 13 ? faker.string.uuid() : "mock-file-react-for-beginners",
159162
author: author,
160163
thumbnail: thumbnail,
161164
type: fileTypes[i],
@@ -177,15 +180,15 @@ class MockDataStore {
177180
// Then create the document with a placeholder rating (will be updated later)
178181
// We need to create a placeholder rating because document and rating have circular references
179182
const placeholderRating: MockRating = {
180-
id: faker.string.uuid(),
183+
id: i != 13 ? faker.string.uuid() : "mock-file-react-for-beginners",
181184
author: author,
182185
document: {} as MockDocument, // Will be updated
183186
rating: i === 3 ? 5 : 0,
184187
timestamp: new Date()
185188
};
186189

187190
const document: MockDocument = {
188-
id: faker.string.uuid(),
191+
id: i != 13 ? faker.string.uuid() : "mock-file-react-for-beginners",
189192
title: documentTitles[i],
190193
description: documentDescriptions[i],
191194
rating: placeholderRating,
@@ -374,7 +377,7 @@ class MockDataStore {
374377
private generateBookmarks(): void {
375378
// Each user will have between 1 and 4 saved documents
376379
for (const user of this.users) {
377-
const bookmarkCount = faker.number.int({ min: 1, max: 4 });
380+
const bookmarkCount = 4;
378381

379382
// Create an array of document indices and shuffle it
380383
const availableDocIndices = Array.from({ length: this.documents.length }, (_, i) => i);
@@ -384,14 +387,12 @@ class MockDataStore {
384387
}
385388

386389
// Use the first bookmarkCount indices
387-
for (let i = 0; i < bookmarkCount; i++) {
388-
const documentIndex = availableDocIndices[i];
389-
const document = this.documents[documentIndex];
390+
for (const d of [...this.documents.slice(0,3), ...this.documents.filter(a => a.id === "mock-file-react-for-beginners")]) {
390391

391392
const bookmark: MockBookmark = {
392393
id: faker.string.uuid(),
393394
user: user,
394-
document: document,
395+
document: d,
395396
timestamp: faker.date.recent({ days: 30 })
396397
};
397398

0 commit comments

Comments
 (0)