Skip to content

Commit

Permalink
Refactor code for better readability and
Browse files Browse the repository at this point in the history
maintainability.
  • Loading branch information
IhsenBouallegue committed Nov 15, 2023
1 parent 508487f commit 4c6aedf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/app/api/links/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ export async function GET(req: NextRequest) {
try {
let items;
if (hubId) {
items = await db.query.links.findMany({
where: eq(links.hubId, hubId),
});
items = await db
.select()
.from(links)
.where(eq(links.hubId, hubId))
.orderBy(links.createdAt);
} else {
items = await db.query.links.findMany();
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/link-card/full-link-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function FullLinkCard({
</div>
<div className="h-1/2 flex flex-col gap-2">
<p className="text-lg font-semibold leading-5">{title}</p>
<p className=" text-muted-foreground">{description}</p>
<p className="text-muted-foreground line-clamp-4">{description}</p>
</div>
</Card>
</NormalOrEditInjector>
Expand Down
4 changes: 3 additions & 1 deletion src/modals/link-modals/link-edit-modal/link-edit-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export function LinkEditModal({
<Icons.trash />
Delete
</Button>
<Button type="submit">Edit</Button>
<Button autoFocus type="submit">
Edit
</Button>
</DialogFooter>
</form>
</Form>
Expand Down

0 comments on commit 4c6aedf

Please sign in to comment.