Skip to content

Commit

Permalink
Merge branch 'main' into mai
Browse files Browse the repository at this point in the history
  • Loading branch information
kimthu09 authored Jan 15, 2024
2 parents dd24882 + 7f3b6b8 commit bcc4277
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 107 deletions.
66 changes: 48 additions & 18 deletions frontend/app/invoice/[invoiceId]/detail-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,59 @@ const DetailLayout = (responseData: any) => {
width={36}
height={36}
></Image>
<h1 className="text-3xl uppercase font-medium">{shop.name}</h1>
<h1 className="xl:text-3xl text-2xl uppercase font-medium">
{shop.name}
</h1>
</div>
{shop.address && shop.address !== "" ? (
<span className="text-lg uppercase font-medium">
<span className="text-base uppercase font-medium printScreen">
Địa chỉ: {shop.address}
</span>
) : null}
{shop.phone && shop.phone !== "" ? (
<span className="text-base font-medium">
<span className="text-base font-medium printScreen">
Số điện thoại: {shop.phone}
</span>
) : null}
{shop.wifiPass && shop.wifiPass !== "" ? (
<span className="text-base font-light">
<span className="text-base font-light printScreen">
Wifi: {shop.wifiPass}
</span>
) : null}
</div>

<div className="flex flex-row justify-between p-4 mb-6 border rounded-md">
<div className="flex flex-col items-end gap-2 text-sm">
<div className="flex flex-col items-stretch gap-2 text-sm">
<div className="flex gap-2">
<span className="font-light">Mã hóa đơn:</span>
<span className="font-light w-[6rem]">Mã hóa đơn:</span>
<span className="font-semibold">{responseData.invoice.id}</span>
</div>
{responseData.invoice.customer && (
<>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Khách hàng:
</span>
<div className="font-semibold flex flex-col">
{responseData.invoice.customer.name}
<span className="font-normal">
({responseData.invoice.customer.phone})
</span>
</div>
</div>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Điểm:
</span>
<div className="font-semibold flex gap-2 text-green-700">
+{" "}
{responseData.invoice.pointReceive.toLocaleString(
"vi-VN"
)}
</div>
</div>
</>
)}
</div>

<div className="flex flex-col items-end gap-2 text-sm">
Expand All @@ -90,19 +118,21 @@ const DetailLayout = (responseData: any) => {
<div className="flex flex-col gap-4">
<InvoiceDetailTable details={details} />
<div className="flex flex-col gap-2">
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
{responseData.invoice.amountPriceUsePoint !== 0 ? (
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
<>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
</>
) : null}
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Thành tiền: </span>
Expand Down
1 change: 1 addition & 0 deletions frontend/app/sale/page-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const SaleScreen = () => {
details: [],
});
mutate(`${endPoint}/v1/customers/all`);
mutate(`${endPoint}/v1/books/all`);
router.refresh();
}
};
Expand Down
15 changes: 14 additions & 1 deletion frontend/app/setting/detail-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";
import ConfirmDialog from "@/components/confirm-dialog";
import Loading from "@/components/loading";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
Expand Down Expand Up @@ -255,6 +254,20 @@ const DetailLayout = () => {
)}
</div>
</div>
<div className="basis-2/3">
<Label htmlFor="add">Địa chỉ</Label>
<Input
id="add"
readOnly={readOnly}
defaultValue={shop?.address ?? ""}
{...register("address")}
></Input>
{errors.address && (
<span className="error___message">
{errors.address.message}
</span>
)}
</div>
<div className="flex gap-4 lg:flex-row flex-col">
<div className="basis-1/2">
<Label htmlFor="accumulatePointPercent">
Expand Down
5 changes: 2 additions & 3 deletions frontend/app/stockmanage/check/add/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import { useSWRConfig } from "swr";
import CheckInsert from "@/components/stock-manage/check-insert";
import createCheckNote from "@/lib/check/createCheckNote";
import { useCurrentUser } from "@/hooks/use-user";
import Loading from "@/components/loading";
import { includesRoles } from "@/lib/utils";
import NoRole from "@/components/no-role";
import ImportSheet from "@/components/book-manage/import-sheet";
import getAllBookForSale from "@/lib/book/getAllBookForSale";
import { useLoading } from "@/hooks/loading-context";
import ImportNoteAddSkeleton from "@/components/skeleton/import-note-add-skeleton";
import InventoryCheckNoteAddSkeleton from "@/components/skeleton/inventory-check-note-add-skeleton";

export const FormSchema = z.object({
id: z.string().max(12, "Tối đa 12 ký tự"),
Expand Down Expand Up @@ -168,7 +167,7 @@ const AddNote = () => {
};
const { currentUser } = useCurrentUser();
if (!currentUser) {
return <ImportNoteAddSkeleton />;
return <InventoryCheckNoteAddSkeleton />;
} else if (
currentUser &&
!includesRoles({
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/stockmanage/import/[importId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ImportDetail = ({ params }: { params: { importId: string } }) => {
});
if (isError) return <div>Failed to load</div>;
else if (!currentUser || isLoading) {
return <ImportNoteDetailSkeleton/>;
return <ImportNoteDetailSkeleton />;
} else if (
currentUser &&
!includesRoles({
Expand All @@ -75,7 +75,7 @@ const ImportDetail = ({ params }: { params: { importId: string } }) => {
<span className="font-light">Mã phiếu nhập</span>
<span>{data.id}</span>
</div>
<div className="flex gap-2 flex-nowrap">
<div className="flex gap-2 flex-wrap justify-end">
<Button
variant={"outline"}
className="p-2"
Expand Down
10 changes: 7 additions & 3 deletions frontend/app/stockmanage/import/add/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import createImportNote from "@/lib/import/createImportNote";
import { Switch } from "@/components/ui/switch";
import { useSWRConfig } from "swr";
import { useCurrentUser } from "@/hooks/use-user";
import Loading from "@/components/loading";
import { includesRoles } from "@/lib/utils";
import NoRole from "@/components/no-role";
import ImportSheet from "@/components/book-manage/import-sheet";
import getAllBookForSale from "@/lib/book/getAllBookForSale";
import { useLoading } from "@/hooks/loading-context";
import InventoryCheckNoteAddSkeleton from "@/components/skeleton/inventory-check-note-add-skeleton";
import ImportNoteAddSkeleton from "@/components/skeleton/import-note-add-skeleton";

export const FormSchema = z.object({
id: z.string().max(12, "Tối đa 12 ký tự"),
Expand Down Expand Up @@ -128,7 +127,7 @@ const AddNote = () => {

const { currentUser } = useCurrentUser();
if (!currentUser) {
return <InventoryCheckNoteAddSkeleton />;
return <ImportNoteAddSkeleton />;
} else if (
currentUser &&
!includesRoles({
Expand Down Expand Up @@ -225,8 +224,13 @@ const AddNote = () => {
<div className="flex-1">
<Label>Nhà cung cấp</Label>
<SupplierList
canAdd
supplierId={supplierId}
setSupplierId={handleSupplierIdSet}
handleSupplierAdded={(supplierId) => {
mutate(`${endPoint}/v1/suppliers/all`);
handleSupplierIdSet(supplierId);
}}
/>
{errors.supplierId && (
<span className="error___message">
Expand Down
7 changes: 6 additions & 1 deletion frontend/app/supplier/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Metadata } from "next";
import { withAuth } from "@/lib/role/withAuth";
import { includesRoles } from "@/lib/utils";
import TableSkeleton from "@/components/skeleton/table-skeleton";
import { Button } from "@/components/ui/button";
export const metadata: Metadata = {
title: "Quản lý nhà cung cấp",
};
Expand All @@ -20,7 +21,11 @@ function SupplierManage({
<div className="flex flex-row justify-between ">
<h1>Danh sách nhà cung cấp</h1>
<div className="flex gap-4">
<CreateDialog />
<CreateDialog>
<Button className="lg:px-4 px-2 whitespace-nowrap">
Thêm nhà cung cấp
</Button>
</CreateDialog>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions frontend/components/customer/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ const CreateDialog = ({
const onSubmit: SubmitHandler<z.infer<typeof SupplierSchema>> = async (
data
) => {
setOpen(false);

const response: Promise<any> = createCustomer(data);
showLoading();
const responseData = await response;
Expand All @@ -67,6 +65,8 @@ const CreateDialog = ({
title: "Thành công",
description: "Thêm khách hàng thành công",
});
setOpen(false);

if (handleCustomerAdded) {
handleCustomerAdded(responseData.data);
}
Expand Down
12 changes: 7 additions & 5 deletions frontend/components/invoice/invoice-detail-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ export const columns: ColumnDef<InvoiceDetailProps>[] = [
{
accessorKey: "name",
header: () => {
return <span className="font-semibold">Tên sách</span>;
return <span className="font-semibold ">Tên sách</span>;
},
cell: ({ row }) => (
<div className="leading-6 flex flex-col">{row.original.book.name}</div>
<div className="leading-6 flex flex-col 2xl:max-w-[20rem] xl:max-w-[14rem] max-w-[8rem]">
{row.original.book.name}
</div>
),
size: 4,
},
{
accessorKey: "amountImport",
header: ({ column }) => (
<div className="flex justify-end whitespace-normal">
<span className="font-semibold">Số lượng</span>
<span className="font-semibold">SL</span>
</div>
),
cell: ({ row }) => {
Expand Down Expand Up @@ -145,8 +147,8 @@ export function InvoiceDetailTable({
},
});
return (
<div className="rounded-md border w-full">
<Table>
<div className="rounded-md border overflow-x-auto min-w-full max-w-[40vw]">
<Table className="min-w-full w-max">
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
Expand Down
56 changes: 42 additions & 14 deletions frontend/components/invoice/print-invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,39 @@ const PrintInvoice = ({
</div>

<div className="flex flex-row justify-between p-4 mb-6 border rounded-md">
<div className="flex flex-col items-end gap-2 text-sm">
<div className="flex flex-col items-stretch gap-2 text-sm">
<div className="flex gap-2">
<span className="font-light">Mã hóa đơn:</span>
<span className="font-light w-[6rem]">Mã hóa đơn:</span>
<span className="font-semibold">
{responseData.invoice.id}
</span>
</div>
{responseData.invoice.customer && (
<>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Khách hàng:
</span>
<div className="font-semibold flex flex-col">
{responseData.invoice.customer.name}
<span className="font-normal">
({responseData.invoice.customer.phone})
</span>
</div>
</div>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Điểm:
</span>
<div className="font-semibold flex gap-2 text-green-700">
+{" "}
{responseData.invoice.pointReceive.toLocaleString(
"vi-VN"
)}
</div>
</div>
</>
)}
</div>

<div className="flex flex-col items-end gap-2 text-sm">
Expand All @@ -96,19 +122,21 @@ const PrintInvoice = ({
<div className="flex flex-col gap-4">
<InvoiceDetailTable details={details} />
<div className="flex flex-col gap-2">
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
{responseData.invoice.amountPriceUsePoint !== 0 ? (
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
<>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
</>
) : null}
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Thành tiền: </span>
Expand Down
1 change: 0 additions & 1 deletion frontend/components/invoice/table-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const TableLayout = async ({
search: search?.toString(),
});
const staffs = await staffsData;

const totalPage = Math.ceil(staffs.paging.total / staffs.paging.limit);
return <InvoiceTable data={staffs.data} totalPage={totalPage} />;
};
Expand Down
6 changes: 5 additions & 1 deletion frontend/components/sale/bill-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ const BillTab = ({
field.value.customerId !== "" &&
shop && (
<Label>
Dùng {field.value.customerPoint} điểm (giảm{" "}
Dùng{" "}
{field.value.customerPoint.toLocaleString(
"vi-VN"
)}{" "}
điểm (giảm{" "}
{toVND(
field.value.customerPoint *
(shop?.usePointPercent ?? 0)
Expand Down
Loading

0 comments on commit bcc4277

Please sign in to comment.