Skip to content

Commit

Permalink
feat(db): Add description field to seed data and display in HTML view
Browse files Browse the repository at this point in the history
  • Loading branch information
wajeht committed Aug 14, 2024
1 parent adad23c commit 558eab5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/db/seeds/01_seeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function seed(knex: Knex): Promise<void> {
.map(() => ({
user_id: faker.helpers.arrayElement(userIds).id,
name: faker.company.name(),
description: faker.internet.url(),
is_active: faker.datatype.boolean(),
created_at: faker.date.past(),
updated_at: faker.date.recent(),
Expand Down
27 changes: 23 additions & 4 deletions src/views/pages/apps.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,31 @@ <h2>Apps</h2>
<% apps.forEach(app => { %>
<article style="border: dashed; padding: 20px; border-radius: 5px; display: flex; flex-direction: column; gap: 5px;">

<h3>
<a href="/apps/<%= app.id %>"><%= app.name %></a>
</h3>
<div style="display: flex; align-items: center; gap: 10px;">
<h3>
<a href="/apps/<%= app.id %>"><%= app.name %></a>
</h3>

<span style="
display: inline-block;
padding: 0px 5px;
font-size: 0.75rem;
border-radius: 5px;
<%= app.is_active ? 'color: red; border: 1px solid red;' : 'color: green; border: 1px solid green;' %>"
>
<%= app.is_active ? 'Active' : 'Inactive' %>
</span>

</div>

<div>
<p><%= app.is_active ? 'Active' : 'Inactive' %></p>
<% if (app.description.match(/^(https?:\/\/|www\.)/i)) { %>
<a href="<%= app.description %>" target="_blank" rel="noopener noreferrer">
<%= app.description %>
</a>
<% } else { %>
<p><%= app.description %></p>
<% } %>
</div>

<div style="display: flex; gap: 20px; align-items: center;">
Expand Down

0 comments on commit 558eab5

Please sign in to comment.