data display on clientSide

This commit is contained in:
tokslaw7
2025-06-22 17:12:32 -04:00
parent 54e6103dde
commit 58384964ba
3 changed files with 1053 additions and 39 deletions
+3 -5
View File
@@ -11,7 +11,6 @@ async function main() {
await prisma.post.deleteMany(); await prisma.post.deleteMany();
await prisma.profile.deleteMany(); await prisma.profile.deleteMany();
// Create 5 users // Create 5 users
const users = []; const users = [];
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
@@ -28,12 +27,11 @@ async function main() {
role: i === 0 ? 'ADMIN' : i === 1 ? 'EDITOR' : 'USER', role: i === 0 ? 'ADMIN' : i === 1 ? 'EDITOR' : 'USER',
}, },
}); });
users.push(user); users.push(user);
console.log(`User created: ${user.username}`); console.log(`User created: ${user.username}`);
} }
// Each user creates 2-4 posts
for (const user of users) { for (const user of users) {
const postCount = faker.number.int({ min: 2, max: 4 }); const postCount = faker.number.int({ min: 2, max: 4 });
for (let i = 0; i < postCount; i++) { for (let i = 0; i < postCount; i++) {
@@ -45,11 +43,11 @@ async function main() {
authorId: user.id, authorId: user.id,
}, },
}); });
console.log(`Created post: ${post.title}`); console.log(`Post created: ${post.title}`);
} }
} }
for (const user of users){ for (const user of users) {
const profile = await prisma.profile.create({ const profile = await prisma.profile.create({
data: { data: {
bio: faker.person.bio(), bio: faker.person.bio(),
+1008
View File
File diff suppressed because it is too large Load Diff
+13 -5
View File
@@ -23,12 +23,20 @@ async function fetchAndDisplayData() {
${data.map(item => ` ${data.map(item => `
<li> <li>
<h2>${item.name}</h2> <h2>${item.name}</h2>
<strong>Role: </strong>${item.role}<br> <strong>Role:</strong> ${item.role}<br>
<strong>Email: </strong>${item.email}<br> <strong>Email:</strong> ${item.email}<br>
</li>` <strong>Username:</strong> ${item.username}<br>
).join('')} <strong>UUID:</strong> ${item.userId}<br>
<strong>Avatar:</strong>${item.avatar}<br>
<strong>Initial Password:</strong> ${item.password}<br>
<strong>Birthdate:</strong> ${new Date(item.birthdate).toDateString()}<br>
<strong>Profile Bio:</strong> ${item.profile?.bio || 'N/A'}<br><br>
<ul>
</ul> </ul>
` </li>
`).join('')}
</ul>
`
dataContainer.innerHTML = html; dataContainer.innerHTML = html;
} catch (error) { } catch (error) {