-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function useBrands() { | ||
// const brands = ref<Brand[]>([]) | ||
|
||
// onMounted(async () => { | ||
// brands.value = await fetchBrands() | ||
// }) | ||
|
||
// return { | ||
// brands | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
<template> | ||
<PageContent page-title="Brands"> | ||
<template #actions> | ||
<PerdButton | ||
small | ||
icon="tabler:plus" | ||
@click="onAddBrandClick" | ||
> | ||
Add brand | ||
</PerdButton> | ||
</template> | ||
|
||
<EmptyState | ||
icon="streamline-emojis:face-screaming-in-fear" | ||
> | ||
Can't load brands data | ||
</EmptyState> | ||
</PageContent> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import PageContent from '~/components/layout/PageContent.vue' | ||
import PerdButton from '~/components/PerdButton.vue' | ||
import EmptyState from '~/components/EmptyState.vue' | ||
definePageMeta({ | ||
layout: 'page' | ||
}) | ||
const router = useRouter() | ||
function onAddBrandClick() { | ||
router.push('/brands/add') | ||
} | ||
</script> | ||
|
||
<style module> | ||
.content { | ||
display: grid; | ||
row-gap: var(--spacing-12); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { asc, count, eq } from 'drizzle-orm' | ||
|
||
interface ReturnData { | ||
readonly id: number; | ||
readonly name: string; | ||
} | ||
|
||
export default defineEventHandler(async (event) : Promise<ReturnData[]> => { | ||
const result = await event.context.db | ||
.select({ | ||
id: tables.brands.id, | ||
name: tables.brands.name, | ||
websiteUrl: tables.brands.websiteUrl, | ||
equipmentCount: count(tables.equipment.id) | ||
}) | ||
.from(tables.brands) | ||
.leftJoin( | ||
tables.equipment, | ||
eq(tables.equipment.brandId, tables.brands.id) | ||
) | ||
.groupBy(tables.brands.id) | ||
.orderBy( | ||
asc(tables.brands.name) | ||
) | ||
.limit(100) | ||
|
||
return result | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters