Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add extended display on pos ui (#4783)
- Loading branch information
1 parent
505faaf
commit 79c54b8
Showing
24 changed files
with
283 additions
and
68 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
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,44 @@ | ||
"use client" | ||
|
||
import { cartAtom } from "@/store/cart.store" | ||
import { useAtomValue } from "jotai" | ||
|
||
import { formatNum } from "@/lib/utils" | ||
|
||
const Components = () => { | ||
const cart = useAtomValue(cartAtom) | ||
const formatIndex = (index: number) => (index + 1).toString().padStart(2, "0") | ||
return ( | ||
<> | ||
<div className="mb-1 flex rounded border-transparent bg-primary p-3 leading-4 text-white font-semibold text-xs text-center"> | ||
<div className="flex w-6/12 text-left"> | ||
<span className="w-1/6 pl-2">#</span> | ||
<span className="w-5/6 ">Барааны нэр</span> | ||
</div> | ||
<span className="w-2/12">Тоо ширхэг</span> | ||
|
||
<span className="w-2/12">Үнэ</span> | ||
<span className="w-2/12">Нийт үнэ</span> | ||
</div> | ||
{cart.map((item, index) => ( | ||
<div | ||
key={index} | ||
className="mb-1 flex items-center rounded bg-gray-100 px-3 text-xs font-semibold h-8 text-center" | ||
> | ||
<div className="flex w-6/12 text-left"> | ||
<span className="w-1/6">{formatIndex(index + 1)}</span> | ||
<span className="w-5/6 ">{item.productName}</span> | ||
</div> | ||
<span className="w-2/12">{item.count}</span> | ||
<span className="w-2/12">{formatNum(item.unitPrice)}₮</span> | ||
<span className="w-2/12"> | ||
{formatNum(item.unitPrice * item.count)}₮ | ||
</span> | ||
|
||
</div> | ||
))} | ||
</> | ||
) | ||
} | ||
|
||
export default Components |
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,16 @@ | ||
import { ReactNode } from "react" | ||
|
||
import HeaderLayout from "@/components/header/headerLayout" | ||
|
||
const Layout = ({ children }: { children: ReactNode }) => { | ||
return ( | ||
<> | ||
<HeaderLayout hideUser> | ||
<span className='w-2/3'/> | ||
</HeaderLayout> | ||
{children} | ||
</> | ||
) | ||
} | ||
|
||
export default Layout |
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,109 @@ | ||
"use client" | ||
|
||
import { useEffect } from "react" | ||
import CustomerType from "@/modules/customer/CustomerType" | ||
import { queries } from "@/modules/orders/graphql" | ||
import { refetchOrderAtom } from "@/store" | ||
import { activeOrderIdAtom } from "@/store/order.store" | ||
import { useQuery } from "@apollo/client" | ||
import { useAtom, useAtomValue } from "jotai" | ||
import { CheckCircle2Icon } from "lucide-react" | ||
|
||
import { IPaidAmount } from "@/types/order.types" | ||
import { getCustomerLabel } from "@/lib/utils" | ||
import { Dialog, DialogContent } from "@/components/ui/dialog" | ||
import { Input } from "@/components/ui/input" | ||
import { Label } from "@/components/ui/label" | ||
|
||
import Cart from "./components/cart" | ||
|
||
const Extended = () => { | ||
const _id = useAtomValue(activeOrderIdAtom) | ||
const [refetchOrder, setRefetchOrder] = useAtom(refetchOrderAtom) | ||
const { data, loading, refetch } = useQuery(queries.orderDetail, { | ||
variables: { | ||
_id, | ||
}, | ||
}) | ||
|
||
useEffect(() => { | ||
if (refetchOrder) { | ||
refetch() | ||
setRefetchOrder(false) | ||
} | ||
}, [refetch, refetchOrder, setRefetchOrder]) | ||
|
||
if (loading) return null | ||
|
||
const { paidAmounts, mobileAmount, cashAmount, customer } = data?.orderDetail | ||
|
||
return ( | ||
<div className="flex flex-auto items-stretch overflow-hidden px-5"> | ||
<div | ||
className="relative flex h-full w-2/3 flex-col overflow-hidden py-4 pr-4 | ||
" | ||
> | ||
<Cart /> | ||
</div> | ||
<div className="flex w-1/3 flex-col border-l p-4 pr-0 relative"> | ||
<div className="flex items-center gap-1 relative"> | ||
<CustomerType className="h-5 w-5" /> | ||
<Input | ||
value={getCustomerLabel(customer || {})} | ||
placeholder="Хэрэглэгч сонгох" | ||
/> | ||
</div> | ||
<div className="mt-2 flex flex-auto flex-col pt-2"> | ||
<div className="flex-auto"> | ||
<Label className="block pb-2">Төлбөрийн төрөл:</Label> | ||
{cashAmount > 0 && ( | ||
<div className="flex flex-auto gap-2 pb-2"> | ||
<div className="w-1/2"> | ||
<Input value="Бэлнээр" /> | ||
</div> | ||
<div className="w-1/2"> | ||
<Input value={cashAmount.toLocaleString()} /> | ||
</div> | ||
</div> | ||
)} | ||
{mobileAmount > 0 && ( | ||
<div className="flex flex-auto gap-2 pb-2"> | ||
<div className="w-1/2"> | ||
<Input value="Бэлнээр" /> | ||
</div> | ||
<div className="w-1/2"> | ||
<Input value={mobileAmount.toLocaleString()} /> | ||
</div> | ||
</div> | ||
)} | ||
{paidAmounts.map((el: IPaidAmount) => ( | ||
<div className="flex flex-auto gap-2 pb-2" key={el._id}> | ||
<div className="w-1/2"> | ||
<Input value={el.type} /> | ||
</div> | ||
<div className="w-1/2"> | ||
<Input value={(el.amount || "").toLocaleString()} /> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
<Dialog open={false}> | ||
<DialogContent> | ||
<div className="flex flex-col items-center py-14 gap-5"> | ||
<CheckCircle2Icon | ||
className="h-20 w-20 text-green-500 animate-bounce " | ||
strokeWidth={1.5} | ||
/> | ||
<p className="text-center text-base font-medium"> | ||
Төлбөр амжилттай төлөгдлөө | ||
</p> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
</div> | ||
) | ||
} | ||
|
||
export default Extended |
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
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
17 changes: 17 additions & 0 deletions
17
pos/modules/checkout/components/cart/cart-header.market.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,17 @@ | ||
const CartHeader = () => { | ||
return ( | ||
<div className="mb-1 flex rounded border-transparent bg-primary px-3.5 py-3 text-sm leading-4 text-white"> | ||
<div className="flex w-5/12"> | ||
<small className="w-1/12">#</small> | ||
<small className="w-11/12">Барааны нэр</small> | ||
</div> | ||
<small className="w-3/12">Тоо ширхэг</small> | ||
<small className="flex w-4/12"> | ||
<span className="w-6/12">Бар код</span> | ||
<span className="w-5/12">Үнэ</span> | ||
</small> | ||
</div> | ||
) | ||
} | ||
|
||
export default CartHeader |
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.