Skip to content

Commit 3cc726f

Browse files
committed
Merge branch 'main' of github.com:LabSyncro/LabSyncro into feat/add-device-page
2 parents f4daafa + b97546a commit 3cc726f

60 files changed

Lines changed: 1594 additions & 483 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

0 Bytes
Binary file not shown.

.env.example

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
DATABASE_USER=admin
2-
DATABASE_HOST=localhost
3-
DATABASE_NAME=labsyncro
4-
DATABASE_PASSWORD=secret
5-
DATABASE_PORT=5432
6-
JWT_SECRET=,
7-
NODE_ENV=,
8-
DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
1+
DATABASE_USER=
2+
DATABASE_HOST=
3+
DATABASE_NAME=
4+
DATABASE_PASSWORD=
5+
DATABASE_PORT=
6+
JWT_SECRET=
7+
NODE_ENV=dev
8+
DATABASE_URL=
9+
AUTH_SECRET=
10+
GOOGLE_CLIENT_ID=
11+
GOOGLE_CLIENT_SECRET=
12+
PRINT_LABELS_ENDPOINT=
13+
AUTH_API_BASE_URL=

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
echo AUTH_SECRET=${{ secrets.AUTH_SECRET }} >> .env
4242
echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env
4343
echo PRINT_LABELS_ENDPOINT=${{ secrets.PRINT_LABELS_ENDPOINT }} >> .env
44+
echo AUTH_API_BASE_URL=${{ secrets.AUTH_API_BASE_URL }} >> .env
4445
4546
- name: Setup Docker Buildx
4647
uses: docker/setup-buildx-action@v3

bun.lockb

14 KB
Binary file not shown.
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
<script setup lang="ts">
2-
const { signIn } = useAuth();
2+
const { signIn, data } = useAuth();
3+
const router = useRouter();
34
45
const handleLogin = async () => {
5-
await signIn('google', { callbackUrl: '/' });
6+
await signIn('google');
7+
if (data.value?.user?.defaultRoute) {
8+
router.push(data.value.user.defaultRoute);
9+
}
610
};
711
</script>
812

913
<template>
10-
<Button class="w-full flex justify-center items-center bg-blue-100 hover:bg-blue-200" @click="handleLogin">
11-
<img class="h-5 w-5 mr-2" src="https://www.svgrepo.com/show/475656/google-color.svg" alt="Google logo">
12-
Sign in with Google
13-
</Button>
14-
</template>
14+
<button
15+
@click="handleLogin"
16+
class="w-full flex items-center justify-center gap-3 px-4 py-3 border border-gray-300 rounded-lg text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-tertiary-darker transition-colors"
17+
>
18+
<img
19+
class="h-5 w-5"
20+
src="https://www.svgrepo.com/show/475656/google-color.svg"
21+
alt="Google logo"
22+
>
23+
<span>Sign in with Google</span>
24+
</button>
25+
</template>

components/app/BorrowReturnDeviceTable/RowAction.vue renamed to components/app/BorrowDeviceTable/RowAction.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<script setup lang="ts">
22
import type { Row } from '@tanstack/vue-table';
33
import { MoreHorizontal } from 'lucide-vue-next';
4-
import { BorrowReturnDeviceSchema, type BorrowReturnDevice } from './schema';
4+
import { BorrowDeviceSchema, type BorrowDevice } from './schema';
55
import { Value } from '@sinclair/typebox/value';
66
77
interface DataTableRowActionsProps {
8-
row: Row<BorrowReturnDevice>
8+
row: Row<BorrowDevice>
99
}
1010
const props = defineProps<DataTableRowActionsProps>();
1111
1212
computed(() => {
1313
const data = props.row.original;
1414
15-
if (Value.Check(BorrowReturnDeviceSchema, data)) {
16-
return data as BorrowReturnDevice;
15+
if (Value.Check(BorrowDeviceSchema, data)) {
16+
return data as BorrowDevice;
1717
} else {
18-
throw new Error('Invalid Borrow Return Table Data Schema');
18+
throw new Error('Invalid Borrow Table Data Schema');
1919
}
2020
});
2121
</script>
File renamed without changes.

components/app/BorrowReturnDeviceTable/column.ts renamed to components/app/BorrowDeviceTable/column.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BorrowReturnDevice } from './schema';
1+
import type { BorrowDevice } from './schema';
22
import { formatDate } from '~/lib/utils';
33
import type { AugmentedColumnDef } from '~/components/common/DataTable/column';
44

@@ -7,7 +7,7 @@ const statusMap = {
77
on_time: 'Đúng hạn',
88
};
99

10-
export const columns: AugmentedColumnDef<BorrowReturnDevice>[] = [
10+
export const columns: AugmentedColumnDef<BorrowDevice>[] = [
1111
{
1212
id: 'name',
1313
title: 'Tên thiết bị',
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
import { receiptService } from '~/services';
3+
import { columns } from './column';
4+
import type { AugmentedColumnDef } from '~/components/common/DataTable/column';
5+
6+
async function fetchData(offset: number, length: number, options: { desc?: boolean, sortField?: string, searchText?: string, searchFields?: string[] }): Promise<{ data: unknown[], totalPages: number }> {
7+
const res = await receiptService.getBorrowReceipts(offset, length, { searchText: options.searchText, searchFields: ['device_kind_id', 'device_kind_name', 'borrowed_place', 'returned_place'], sortField: options.sortField as any, desc: options.desc });
8+
return {
9+
data: res.receipts.map((receipt) => ({
10+
...receipt,
11+
image: receipt.mainImage
12+
})),
13+
totalPages: res.totalPages,
14+
};
15+
}
16+
17+
</script>
18+
19+
<template>
20+
<DataTable :selectable="true" :searchable="true" :qrable="true" :fetch-fn="fetchData"
21+
:columns="columns as AugmentedColumnDef<unknown>[]" />
22+
</template>

components/app/BorrowReturnDeviceTable/schema.ts renamed to components/app/BorrowDeviceTable/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Type } from '@sinclair/typebox';
22
import type { Static } from '@sinclair/typebox';
33

4-
export const BorrowReturnDeviceSchema = Type.Object({
4+
export const BorrowDeviceSchema = Type.Object({
55
id: Type.Number(),
66
name: Type.String(),
77
image: Type.String(),
@@ -13,4 +13,4 @@ export const BorrowReturnDeviceSchema = Type.Object({
1313
status: Type.Union([Type.Literal('on_time'), Type.Literal('late')]),
1414
});
1515

16-
export type BorrowReturnDevice = Static<typeof BorrowReturnDeviceSchema>;
16+
export type BorrowDevice = Static<typeof BorrowDeviceSchema>;

0 commit comments

Comments
 (0)