-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,928 additions
and
456 deletions.
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
70 changes: 70 additions & 0 deletions
70
book-store-management/app/invoice/[invoiceId]/detail-layout.tsx
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,70 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { InvoiceDetailTable } from "@/components/invoice/invoice-detail-table"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Card, CardContent } from "@/components/ui/card"; | ||
import { toVND } from "@/lib/utils"; | ||
import Image from "next/image"; | ||
import { useRef } from "react"; | ||
import ReactToPrint from "react-to-print"; | ||
import { InvoiceDetailProps } from "./page"; | ||
import { FaPrint } from "react-icons/fa"; | ||
const DetailLayout = (responseData: any) => { | ||
const componentRef = useRef(null); | ||
const details = responseData.details as InvoiceDetailProps[]; | ||
return ( | ||
<Card> | ||
<CardContent className="flex flex-col p-0 gap-4 relative"> | ||
<ReactToPrint | ||
trigger={() => { | ||
return ( | ||
<Button | ||
variant={"outline"} | ||
className="absolute top-6 right-6 flex gap-2" | ||
> | ||
<FaPrint className="w-5 h-5 text-primary" /> | ||
In | ||
</Button> | ||
); | ||
}} | ||
content={() => componentRef.current} | ||
/> | ||
<div ref={componentRef} className="p-6 "> | ||
<div className="flex justify-center gap-2 mb-6"> | ||
<Image | ||
className="object-contain w-auto h-auto" | ||
src="/android-chrome-192x192.png" | ||
priority | ||
alt="logo" | ||
width={50} | ||
height={50} | ||
></Image> | ||
<h1 className=" py-6 text-3xl uppercase font-medium">Nhà sách</h1> | ||
</div> | ||
|
||
<div className="flex flex-row justify-between p-4 mb-6 border rounded-md"> | ||
<div className="flex gap-2"> | ||
<span className="font-light">Mã hóa đơn:</span> | ||
<span className="font-semibold">{responseData.id}</span> | ||
</div> | ||
<div className="flex flex-col items-end gap-2 text-sm"> | ||
<span className="font-semibold"> | ||
{new Date(responseData.createdAt).toLocaleDateString("vi-VN")} | ||
</span> | ||
<span>Nhân viên: {responseData.createdBy.name}</span> | ||
</div> | ||
</div> | ||
<div className="flex flex-col gap-4"> | ||
<InvoiceDetailTable {...details} /> | ||
<div className="flex justify-end space-x-2 py-4 font-semibold"> | ||
<span>Tổng tiền: </span> | ||
<span>{toVND(responseData.totalPrice)}</span> | ||
</div> | ||
</div> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default DetailLayout; |
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
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 @@ | ||
import TableLayout from "./table-layout"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Đầu sách", | ||
}; | ||
const BookTitleScreen = () => { | ||
return <TableLayout />; | ||
}; | ||
|
||
export default BookTitleScreen; |
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,80 @@ | ||
"use client"; | ||
|
||
import CreateTitleDialog from "@/components/book-manage/create-title-dialog"; | ||
import { TitleTable } from "@/components/book-manage/title-table"; | ||
import { Button } from "@/components/ui/button"; | ||
import { endPoint } from "@/constants"; | ||
import { useRouter, useSearchParams } from "next/navigation"; | ||
import { useSWRConfig } from "swr"; | ||
|
||
export const getFilterString = () => { | ||
const searchParams = useSearchParams(); | ||
const minPrice = searchParams.get("minPrice") ?? undefined; | ||
const maxPrice = searchParams.get("maxPrice") ?? undefined; | ||
const createdAtFrom = searchParams.get("createdAtFrom") ?? undefined; | ||
const createdAtTo = searchParams.get("createdAtTo") ?? undefined; | ||
|
||
const search = searchParams.get("search") ?? undefined; | ||
|
||
let filters = [{ type: "", value: "" }]; | ||
filters.pop(); | ||
if (maxPrice) { | ||
filters = filters.concat({ type: "maxPrice", value: maxPrice }); | ||
} | ||
if (minPrice) { | ||
filters = filters.concat({ type: "minPrice", value: minPrice }); | ||
} | ||
if (search) { | ||
filters = filters.concat({ type: "search", value: search }); | ||
} | ||
if (createdAtFrom) { | ||
filters = filters.concat({ type: "createdAtFrom", value: createdAtFrom }); | ||
} | ||
if (createdAtTo) { | ||
filters = filters.concat({ type: "createdAtTo", value: createdAtTo }); | ||
} | ||
let stringToFilter = ""; | ||
filters.forEach((item) => { | ||
stringToFilter = stringToFilter.concat(`&${item.type}=${item.value}`); | ||
}); | ||
return { stringToFilter: stringToFilter, filters: filters }; | ||
}; | ||
|
||
const TableLayout = () => { | ||
const router = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const { mutate } = useSWRConfig(); | ||
|
||
const { filters, stringToFilter } = getFilterString(); | ||
const page = searchParams.get("page") ?? "1"; | ||
|
||
const handleTitleAdded = async (titleId: string) => { | ||
mutate( | ||
`${endPoint}/v1/booktitles?page=${page ?? 1}&limit=10${ | ||
stringToFilter ?? "" | ||
}` | ||
); | ||
// const newTitleList = await mutate(); | ||
// setTitle( | ||
// newTitleList?.data.find((item: BookTitle) => item.id === titleId) | ||
// ); | ||
// handleTitleSet(titleId); | ||
router.refresh(); | ||
}; | ||
return ( | ||
<div className="col"> | ||
<div className="flex flex-row justify-between items-center"> | ||
<h1>Danh sách đầu sách</h1> | ||
<CreateTitleDialog handleTitleAdded={handleTitleAdded}> | ||
<Button>Thêm đầu sách</Button> | ||
</CreateTitleDialog> | ||
</div> | ||
|
||
<div className="my-4 p-3 sha bg-white shadow-[0_1px_3px_0_rgba(0,0,0,0.2)]"> | ||
<TitleTable /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TableLayout; |
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
Oops, something went wrong.