| 1 |
import { registry } from "@web/core/registry"; |
| 2 |
import { usePos } from "@point_of_sale/app/hooks/pos_hook"; |
| 3 |
import { Component } from "@odoo/owl"; |
| 4 |
import { useService } from "@web/core/utils/hooks"; |
| 5 |
import { useTime } from "@point_of_sale/app/hooks/time_hook"; |
| 6 |
import { _t } from "@web/core/l10n/translation"; |
| 7 |
|
| 8 |
export class LoginScreen extends Component { |
| 9 |
static template = "point_of_sale.LoginScreen"; |
| 10 |
static props = {}; |
| 11 |
static storeOnOrder = false; |
| 12 |
setup() { |
| 13 |
this.pos = usePos(); |
| 14 |
this.dialog = useService("dialog"); |
| 15 |
this.ui = useService("ui"); |
| 16 |
this.time = useTime(); |
| 17 |
} |
| 18 |
|
| 19 |
openRegister() { |
| 20 |
this.selectUser(); |
| 21 |
} |
| 22 |
|
| 23 |
selectUser() { |
| 24 |
this.selectOneCashier(this.pos.user); |
| 25 |
} |
| 26 |
cashierLogIn() { |
| 27 |
const selectedScreen = |
| 28 |
this.pos.previousScreen && this.pos.previousScreen !== "LoginScreen" |
| 29 |
? this.pos.previousScreen |
| 30 |
: this.pos.defaultPage; |
| 31 |
const order = this.pos.getOrder(); |
| 32 |
if (!order && selectedScreen.page === "ProductScreen") { |
| 33 |
this.pos.addNewOrder(); |
| 34 |
} |
| 35 |
const params = |
| 36 |
selectedScreen.page === "ProductScreen" ? { orderUuid: this.pos.getOrder().uuid } : {}; |
| 37 |
this.pos.navigate(selectedScreen.page, params); |
| 38 |
this.pos.hasLoggedIn = true; |
| 39 |
} |
| 40 |
selectOneCashier(cashier) { |
| 41 |
this.pos.setCashier(cashier); |
| 42 |
this.cashierLogIn(); |
| 43 |
} |
| 44 |
get backBtnName() { |
| 45 |
return _t("Backend"); |
| 46 |
} |
| 47 |
clickBack() { |
| 48 |
this.pos.closePos(); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
registry.category("pos_pages").add("LoginScreen", { |
| 53 |
name: "LoginScreen", |
| 54 |
component: LoginScreen, |
| 55 |
route: `/pos/ui/${odoo.pos_config_id}/login`, |
| 56 |
params: {}, |
| 57 |
}); |