Debian Codegraph @

addons/point_of_sale/static/src/customer_display/customer_display.js

raw
1 import { Component, useEffect, whenReady, useRef } from "@odoo/owl";
2 import { OdooLogo } from "@point_of_sale/app/components/odoo_logo/odoo_logo";
3 import { useSingleDialog } from "@point_of_sale/customer_display/utils";
4 import { MainComponentsContainer } from "@web/core/main_components_container";
5 import { session } from "@web/session";
6 import { useService } from "@web/core/utils/hooks";
7 import { mountComponent } from "@web/env";
8 import { TagsList } from "@web/core/tags_list/tags_list";
9 import { CustomerFacingQR } from "./customer_facing_qr";
10
11 export class CustomerDisplay extends Component {
12 static template = "point_of_sale.CustomerDisplay";
13 static components = { OdooLogo, MainComponentsContainer, TagsList };
14 static props = [];
15
16 setup() {
17 this.session = session;
18 this.dialog = useService("dialog");
19 this.order = useService("customer_display_data");
20 const singleDialog = useSingleDialog();
21
22 this.scrollableRef = useRef("scrollable");
23 useEffect(() => {
24 this.scrollableRef.el
25 ?.querySelector(".orderline.selected")
26 ?.scrollIntoView({ behavior: "smooth", block: "start" });
27 });
28
29 useEffect(
30 (qrPaymentData) => {
31 if (qrPaymentData) {
32 singleDialog.open(CustomerFacingQR, qrPaymentData);
33 } else {
34 singleDialog.close();
35 }
36 },
37 () => [this.order.qrPaymentData]
38 );
39 }
40
41 getInternalNotes() {
42 return JSON.parse(this.line.internalNote || "[]");
43 }
44 }
45
46 whenReady(() => mountComponent(CustomerDisplay, document.body));