diff --git a/mirzaev/arming_bot/system/controllers/catalog.php b/mirzaev/arming_bot/system/controllers/catalog.php index 1a7aa8b..f700fed 100755 --- a/mirzaev/arming_bot/system/controllers/catalog.php +++ b/mirzaev/arming_bot/system/controllers/catalog.php @@ -148,7 +148,7 @@ final class catalog extends core $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: ['catalog_filters_brand' => $brand ?? null])); // Writing to the current implementator of the buffer - $this->session->buffer = ['catalog' => ['filters' => ['brand' => $brand ?? null]]] + $this->session->buffer; + $this->session->buffer = ['catalog' => ['filters' => ['brand' => $brand ?? null]]] + $this->session->buffer ?? []; // Initialize buffer of filters query (AQL) $_sort = 'd.position ASC, d.name ASC, d.created DESC'; diff --git a/mirzaev/arming_bot/system/controllers/delivery.php b/mirzaev/arming_bot/system/controllers/delivery.php index 843c523..825c198 100755 --- a/mirzaev/arming_bot/system/controllers/delivery.php +++ b/mirzaev/arming_bot/system/controllers/delivery.php @@ -78,7 +78,7 @@ final class delivery extends core 'ready' => false ]; - if (!empty($company)) { + if (isset($company)) { // Received company name if (mb_strlen($company) < 65) { @@ -113,6 +113,15 @@ final class delivery extends core // Writing readiness status to the buffer of the response $response['ready'] = true; + + // Writing to the session buffer + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [$name = 'delivery_' . $delivery['company'] . '_ready' => true])); + + // Writing to the account buffer + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [$name => true])); + + // Deinitializing unnecessary variables + unset($name); } } @@ -125,7 +134,7 @@ final class delivery extends core // Deinitializing variable for normalized value of the parameter unset($normalized); } - } else if (!empty($location)) { + } else if (isset($location)) { // Received location name if (mb_strlen($location) < 257) { @@ -143,23 +152,23 @@ final class delivery extends core // Deinitializing unnecessary variables unset($matches); - if (!empty($separated)) { - // Serapated location name + // Initialization buffer of delivery parameters + $delivery = $this->account?->buffer['delivery'] ?? $this->session?->buffer['delivery'] ?? []; - // Declaring variable for normalized separated values of location name - $normalized = []; + if (isset($delivery['company'])) { + // Initialized delivery company - // Normalizing location name - foreach ($separated as $value) $normalized[] = mb_ucfirst($value); + if (!empty($separated)) { + // Serapated location name - // Deinitializing unnecessary variables - unset($separated, $value); + // Declaring variable for normalized separated values of location name + $normalized = []; - // Initialization buffer of delivery parameters - $delivery = $this->account?->buffer['delivery'] ?? $this->session?->buffer['delivery'] ?? []; + // Normalizing location name + foreach ($separated as $value) $normalized[] = mb_ucfirst($value); - if (isset($delivery['company'])) { - // Initialized delivery company + // Deinitializing unnecessary variables + unset($separated, $value); // Declaring of universalized locations buffer $locations = null; @@ -185,7 +194,7 @@ final class delivery extends core } // Deinitializing of response data from CDEK - unset($cdek, $location); + unset($cdek); } if (!empty($locations)) { @@ -197,13 +206,13 @@ final class delivery extends core // Initialization of 80% of received input values (required minimum to match location characteristics) $minimum = count($normalized) * 80 / 100; - foreach ($locations as $location) { + foreach ($locations as $_location) { // Iterating over locations // Declaring variable with score of matching input values with location characteristics $score = 0; - foreach ([$location['name'], ...$location['structure']] as $value) { + foreach ([$_location['name'], ...$_location['structure']] as $value) { // Iterating over location characteristics foreach ($normalized as $_value) { @@ -219,7 +228,7 @@ final class delivery extends core // More than $minimum matches found // Writing to buffer of validated locations by normalized parts of location name - $buffer[] = $location; + $buffer[] = $_location; // Exit from iteration of location characteristics break 2; @@ -236,7 +245,7 @@ final class delivery extends core } // Deinitializing unnecessary variables - unset($location); + unset($_location); // Reinitializating locations from buffer of validated locations by input values $locations = $buffer; @@ -253,10 +262,13 @@ final class delivery extends core // Deinitializing unnecessary variables unset($name); + // Writing result value of location name + $result = $locations[0]['name'] . ', ' . implode(', ', array_reverse($locations[0]['structure'])); + // Writing location data to the buffer of the response /* $response['location'] = [ 'identifier' => $locations[0]['identifier'], - 'input' => $result = $locations[0]['name'] . ', ' . implode(', ', array_reverse($locations[0]['structure'])) + 'input' => $result ]; */ if (!empty($delivery[$delivery['company']]['street'])) { @@ -264,6 +276,34 @@ final class delivery extends core // Writing readiness status to the buffer of the response $response['ready'] = true; + + // Writing to the session buffer + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [$name = 'delivery_' . $delivery['company'] . '_ready' => true])); + + // Writing to the account buffer + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [$name => true])); + + // Deinitializing unnecessary variables + unset($name); + } else { + // Not initialized required parameters + + // Writing to the session buffer + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [ + $name_ready = 'delivery_' . $delivery['company'] . '_ready' => false, + $name_cost = 'delivery_' . $delivery['company'] . '_cost' => null, + $name_days = 'delivery_' . $delivery['company'] . '_days' => null + ])); + + // Writing to the account buffer + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [ + $name_ready => false, + $name_cost => null, + $name_days => null + ])); + + // Deinitializing unnecessary variables + unset($name_ready, $name_cost, $name_days); } // Writing status of execution to the buffer of the response @@ -275,29 +315,39 @@ final class delivery extends core // Not identificated location // Writing to the session buffer - $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [$name = 'delivery_' . $delivery['company'] . '_location' => null])); + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [ + $name_location = 'delivery_' . $delivery['company'] . '_location' => null, + $name_ready = 'delivery_' . $delivery['company'] . '_ready' => false, + $name_cost = 'delivery_' . $delivery['company'] . '_cost' => null, + $name_days = 'delivery_' . $delivery['company'] . '_days' => null + ])); // Writing to the account buffer - $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [$name => null])); + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [ + $name_location => null, + $name_ready => false, + $name_cost => null, + $name_days => null + ])); // Deinitializing unnecessary variables - unset($name); + unset($name_location, $name_ready, $name_cost, $name_days); // Declaring buffer of data to send $buffer = []; - foreach ($locations as $location) { + foreach ($locations as $_location) { // Iterating over locations // Writing to buffer of data to send $buffer[] = [ - 'name' => $location['name'], - 'structure' => $location['structure'] + 'name' => $_location['name'], + 'structure' => $_location['structure'] ]; } // Deinitializing unnecessary variables - unset($location); + unset($_location); // Writing locations into response buffer $response['locations'] = $buffer; @@ -309,33 +359,66 @@ final class delivery extends core // Not found locations // Writing to the session buffer - $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [$name = 'delivery_' . $delivery['company'] . '_location' => null])); + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [ + $name_location = 'delivery_' . $delivery['company'] . '_location' => null, + $name_ready = 'delivery_' . $delivery['company'] . '_ready' => false, + $name_cost = 'delivery_' . $delivery['company'] . '_cost' => null, + $name_days = 'delivery_' . $delivery['company'] . '_days' => null + ])); // Writing to the account buffer - $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [$name => null])); + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [ + $name_location => null, + $name_ready => false, + $name_cost => null, + $name_days => null + ])); // Deinitializing unnecessary variables - unset($name); + unset($name_location, $name_ready, $name_cost, $name_days); } // Deinitializing unnecessary variables - unset($locations); - } + unset($normalized); + } else { + // Value is empty after separating - // Deinitializing unnecessary variables - unset($delivery, $normalized); + // Not initialized required parameters + + // Writing to the session buffer + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [ + $name_location = 'delivery_' . $delivery['company'] . '_location' => null, + $name_ready = 'delivery_' . $delivery['company'] . '_ready' => false, + $name_cost = 'delivery_' . $delivery['company'] . '_cost' => null, + $name_days = 'delivery_' . $delivery['company'] . '_days' => null + ])); + + // Writing to the account buffer + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [ + $name_location => null, + $name_ready => false, + $name_cost => null, + $name_days => null + ])); + + // Deinitializing unnecessary variables + unset($name_location, $name_ready, $name_cost, $name_days); + } } + // Deinitializing unnecessary variables + unset($delivery, $normalized); + // Writing to the session buffer - $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: ['delivery_location' => $result])); + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: ['delivery_location' => empty($result) ? $location : $result])); // Writing to the account buffer - $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: ['delivery_location' => $result])); + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: ['delivery_location' => empty($result) ? $location : $result])); // Deinitializing unnecessary variables - unset($result, $normalized); + unset($location, $result, $normalized); } - } else if (!empty($street)) { + } else if (isset($street)) { // Received sreet if (mb_strlen($street) < 129) { @@ -365,11 +448,39 @@ final class delivery extends core // Deinitializing unnecessary variables unset($name); - if (!empty($delivery[$delivery['company']]['location'])) { + if (!empty($normalized) && !empty($delivery[$delivery['company']]['location'])) { // Required parameters initialized: company, location, street // Writing readiness status to the buffer of the response $response['ready'] = true; + + // Writing to the session buffer + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [$name = 'delivery_' . $delivery['company'] . '_ready' => true])); + + // Writing to the account buffer + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [$name => true])); + + // Deinitializing unnecessary variables + unset($name); + } else { + // Not initialized required parameters + + // Writing to the session buffer + $this->core->request(new request('PATCH', '/session/write', protocol::http_3, parameters: [ + $name_ready = 'delivery_' . $delivery['company'] . '_ready' => false, + $name_cost = 'delivery_' . $delivery['company'] . '_cost' => null, + $name_days = 'delivery_' . $delivery['company'] . '_days' => null + ])); + + // Writing to the account buffer + $this->core->request(new request('PATCH', '/account/write', protocol::http_3, parameters: [ + $name_ready => false, + $name_cost => null, + $name_days => null + ])); + + // Deinitializing unnecessary variables + unset($name_ready, $name_cost, $name_days); } // Writing status of execution to the buffer of the response diff --git a/mirzaev/arming_bot/system/controllers/order.php b/mirzaev/arming_bot/system/controllers/order.php new file mode 100755 index 0000000..d955fd5 --- /dev/null +++ b/mirzaev/arming_bot/system/controllers/order.php @@ -0,0 +1,477 @@ + + */ +final class cart extends core +{ + /** + * Cart + * + * @var model|null $cart Instance of the cart + */ + protected readonly ?model $cart; + + /** + * Errors + * + * @var array $errors Registry of errors + */ + protected array $errors = [ + 'session' => [], + 'account' => [], + 'menu' => [], + 'cart' => [] + ]; + + /** + * Index + * + * HTML-document with shopping cart and delivery settings + * + * @param null + */ + public function index(): null + { + if (isset($menu)) { + // + + } else { + // Not received ... menu + + // Search for filters and write to the buffer of global variables of view templater + $this->view->menu = menu::_read( + return: 'MERGE(d, { name: d.name.@language })', + sort: 'd.style.order ASC, d.created DESC, d._key DESC', + amount: 4, + parameters: ['language' => $this->language->name], + errors: $this->errors['menu'] + ); + } + + // Initializing the cart + $this->cart ??= $this->account?->cart() ?? $this->session?->cart(); + + // Initializing the cart data + $this->view->cart = [ + 'summary' => $this->cart?->summary(currency: $this->currency), + 'products' => $this->cart?->products(language: $this->language, currency: $this->currency) + ]; + + // Initializing types of avaiabld deliveries + $this->view->deliveries = [ + 'cdek' => [ + 'label' => 'CDEK' + ] + ]; + + if (str_contains($this->request->headers['accept'], content::json->value)) { + // Request for JSON response + + // Sending response + $this->response + ->start() + ->clean() + ->sse() + ->json([ + 'main' => '', + 'errors' => $this->errors + ]) + ->validate($this->request) + ?->body() + ->end(); + } else if (str_contains($this->request->headers['accept'], content::any->value)) { + // Request for any response + + // Render page + $page = $this->view->render('cart/page.html', [ + 'h2' => $this->language === language::ru ? 'Корзина' : 'Cart' // @see https://git.mirzaev.sexy/mirzaev/huesos/issues/1 + ]); + + // Sending response + $this->response + ->start() + ->clean() + ->sse() + ->write($page) + ->validate($this->request) + ?->body() + ->end(); + + // Deinitializing rendered page + unset($page); + } + + // Exit (success/fail) + return null; + } + + /** + * Product + * + * Change status of the product in the cart + * + * @param int|string|null $identifier Product identifier + * @param string|null $type Action type (toggle, write, delete, set) + * @param int|string|null $amount Amount of actions with the product (for write, delete and differently used by set) + * + * @return null + * + * @todo + * 1. Add a limit on adding products to the cart based on the number of products in stock + */ + public function product( + int|string|null $identifier = null, + ?string $type = null, + int|string|null $amount = null + ): null { + if (str_contains($this->request->headers['accept'], content::json->value)) { + // Request for JSON response + + // Declaring buffer with amount of the product in the cart + $cart = 0; + + // Validating @todo add throwing errors + if (isset($identifier) && preg_match('/[\d]+/', urldecode($identifier), $matches)) $identifier = (int) $matches[0]; + else unset($identifier); + + if (isset($identifier)) { + // Received and validated identfier of the product + + // Search for the product + $product = product::read( + filter: "d.identifier == @identifier && d.deleted != true && d.hidden != true", + sort: 'd.created DESC', + amount: 1, + parameters: ['identifier' => $identifier], + errors: $this->errors['cart'] + ); + + if ($product instanceof product) { + // Initialized the product + + // Initializing the cart + $this->cart ??= $this->account?->cart() ?? $this->session?->cart(); + + if ($this->cart instanceof model) { + // Initialized the cart + + // Initializing buffer with amount of the product in the cart + $cart = $this->cart->count(product: $product, limit: 100, errors: $this->errors['cart']) ?? 0; + + if ($this->cart instanceof model) { + // Initialized the cart + + // Validating @todo add throwing errors + if (isset($type) && preg_match('/[\w]+/', urldecode($type), $matches)) $type = $matches[0]; + else unset($type); + + if (isset($type)) { + // Received and validated type of action with the product + + if ($type === 'toggle') { + // Write the product to the cart if is not in the cart and vice versa + + if ($cart > 0) { + // The cart has the product + + // Deleting the product from the cart + $this->cart->delete(product: $product, amount: $cart, errors: $this->errors['cart']); + + // Reinitializing the buffer with amount of the product in the cart + $cart = 0; + } else { + // The cart has no the product + + // Writing the product to the cart + $this->cart->write(product: $product, amount: 1, errors: $this->errors['cart']); + + // Reinitializing the buffer with amount of the product in the cart + $cart = 1; + } + } else { + // Received not the "toggle" command + + // Validating @todo add throwing errors + if (isset($amount) && preg_match('/[\d]+/', urldecode($amount), $matches)) $amount = (int) $matches[0]; + else unset($amount); + + if (isset($amount)) { + // Received and validated amount parameter for action with the product + + if ($type === 'write') { + // Increase amount of the product in the cart + + if ($cart + $amount < 101) { + // Validated amount to wrting + + // Writing the product to the cart + $this->cart->write(product: $product, amount: $amount, errors: $this->errors['cart']); + + // Reinitialize the buffer with amount of the product in the cart + $cart += $amount; + } + } else if ($type === 'delete') { + // Decrease amount of the product in the cart + + if ($cart - $amount > -1) { + // Validated amount to deleting + + // Deleting the product from the cart + $this->cart->delete(product: $product, amount: $amount, errors: $this->errors['cart']); + + // Reinitialize the buffer with amount of the product in the cart + $cart -= $amount; + } + } else if ($type === 'set') { + // Set amount of the product in the cart + + if ($amount > -1 && $amount < 101) { + // Validated amount to setting + + if ($amount > $cart) { + // Requested amount more than actual amount of the product in the cart + + // Writing the product to the cart + $this->cart->write(product: $product, amount: $amount - $cart, errors: $this->errors['cart']); + } else { + // Requested amount less than actual amount of the product in the cart + + // Deleting the product from the cart + $this->cart->delete(product: $product, amount: $cart - $amount, errors: $this->errors['cart']); + } + + // Reinitializing the buffer with amount of the product in the cart + $cart = $amount; + } + } + } + } + } + } + } + } + } + + // Sending response + $this->response + ->start() + ->clean() + ->sse() + ->json([ + 'amount' => $cart, // $cart does not store a real value, but is calculated without a repeated request to ArangoDB + 'errors' => $this->errors + ]) + ->validate($this->request) + ?->body() + ->end(); + + // Deinitializing buffer with amount of the product in the cart + unset($cart); + } + + // Exit (success/fail) + return null; + } + + /** + * Summary + * + * Information about products in the cart + * + * @return null + */ + public function summary(): null + { + if (str_contains($this->request->headers['accept'], content::json->value)) { + // Request for JSON response + + // Initializing the cart + $this->cart ??= $this->account?->cart() ?? $this->session?->cart(); + + if ($this->cart instanceof model) { + // Initialized the cart + + // Initializing summary data of the cart + $summary = $this->cart?->summary(currency: $this->currency, errors: $this->errors['cart']); + + // Sending response + $this->response + ->start() + ->clean() + ->sse() + ->json([ + 'cost' => $summary['cost'] ?? 0, + 'amount' => $summary['amount'] ?? 0, + 'errors' => $this->errors + ]) + ->validate($this->request) + ?->body() + ->end(); + + // Deinitializing summary data of the cart + unset($summary); + } + } + + // Exit (success/fail) + return null; + } + + /** + * Share + * + * Share the cart + * + * @return null + */ + public function share(): null + { + if (str_contains($this->request->headers['accept'], content::json->value)) { + // Request for JSON response + + // Initializing the cart + $this->cart ??= $this->account?->cart() ?? $this->session?->cart(); + + if ($this->cart instanceof model) { + // Initialized the cart + + if ($share = $this->cart->share ?? $this->cart->share()) { + // The cart is available for sharing + + // Sending response + $this->response + ->start() + ->clean() + ->sse() + ->json([ + 'share' => $share, + 'errors' => $this->errors + ]) + ->validate($this->request) + ?->body() + ->end(); + } + + // Deinitializing unnecessary variables + unset($hash); + } + } + + // Exit (success/fail) + return null; + } + + /** + * Pay + * + * Pay for the cart + * + * @return null + */ + public function pay(): null + { + if (str_contains($this->request->headers['accept'], content::json->value)) { + // Request for JSON response + + // Initializing the cart + $this->cart ??= $this->account?->cart() ?? $this->session?->cart(); + + if ($this->cart instanceof model) { + // Initialized the cart + + if ($share = $this->cart->share ?? $this->cart->share()) { + // The cart is available for sharing + + // Sending response + $this->response + ->start() + ->clean() + ->sse() + ->json([ + 'share' => $share, + 'errors' => $this->errors + ]) + ->validate($this->request) + ?->body() + ->end(); + } + + // Deinitializing unnecessary variables + unset($hash); + } + } + + // Exit (success/fail) + return null; + } + + /** + * Robokassa + * + * HTML-document with robokassa iframe + * + * @param null + * + * @todo THIS MUST BE A PAYMENT OF ORDER IN THE FUTURE, NOT CART + */ + public function robokassa(): null + { + // Initializing the cart + $this->cart ??= $this->account?->cart() ?? $this->session?->cart(); + + // Initializing the cart data + $this->view->cart = $this->cart; + $this->view->summary = $this->cart?->summary(currency: $this->currency); + + if (str_contains($this->request->headers['accept'], content::any->value)) { + // Request for any response + + // Render page + $page = $this->view->render('iframes/robokassa.html'); + + // Sending response + $this->response + ->start() + ->clean() + ->sse() + ->write($page) + ->validate($this->request) + ?->body() + ->end(); + + // Deinitializing rendered page + unset($page); + } + + // Exit (success/fail) + return null; + } +} diff --git a/mirzaev/arming_bot/system/public/js/modules/delivery.mjs b/mirzaev/arming_bot/system/public/js/modules/delivery.mjs index 9dca1d3..5d29a3e 100755 --- a/mirzaev/arming_bot/system/public/js/modules/delivery.mjs +++ b/mirzaev/arming_bot/system/public/js/modules/delivery.mjs @@ -49,6 +49,9 @@ export default class delivery { order.setAttribute("disabled", true); } + // Initializing the delivery data request
element + const request = document.getElementById("delivery_request"); + /** * @name Resolved * @@ -86,10 +89,26 @@ export default class delivery { order.removeAttribute("disabled"); } - // Calculating delivery - this.calculate(); + if (request instanceof HTMLElement) { + // Initializeg the delivery data request
element + + // Hiding the delivery data request
element + request.classList.add("deleted"); + } + } else { + // Not received readiness status or readiness status is false + + if (request instanceof HTMLElement) { + // Initializeg the delivery data request
element + + // Hiding the delivery data request
element + request.classList.remove("deleted"); + } } + // Calculating delivery + this.calculate(); + if (json.company) { // Received company property @@ -181,6 +200,9 @@ export default class delivery { order.setAttribute("disabled", true); } + // Initializing the delivery data request
element + const request = document.getElementById("delivery_request"); + /** * @name Resolved * @@ -215,10 +237,26 @@ export default class delivery { order.removeAttribute("disabled"); } - // Calculating delivery - this.calculate(); + if (request instanceof HTMLElement) { + // Initializeg the delivery data request
element + + // Hiding the delivery data request
element + request.classList.add("deleted"); + } + } else { + // Not received readiness status or readiness status is false + + if (request instanceof HTMLElement) { + // Initializeg the delivery data request
element + + // Hiding the delivery data request
element + request.classList.remove("deleted"); + } } + // Calculating delivery + this.calculate(); + if (json.location) { // Received location @@ -389,6 +427,9 @@ export default class delivery { order.setAttribute("disabled", true); } + // Initializing the delivery data request
element + const request = document.getElementById("delivery_request"); + /** * @name Resolved * @@ -423,16 +464,32 @@ export default class delivery { order.removeAttribute("disabled"); } + if (request instanceof HTMLElement) { + // Initializeg the delivery data request
element + + // Hiding the delivery data request
element + request.classList.add("deleted"); + } + core.modules.connect("telegram").then(() => { // Imported the telegram module core.telegram.api.HapticFeedback.notificationOccurred("success"); }); + } else { + // Not received readiness status or readiness status is false - // Calculating delivery - this.calculate(); + if (request instanceof HTMLElement) { + // Initializeg the delivery data request
element + + // Hiding the delivery data request
element + request.classList.remove("deleted"); + } } + // Calculating delivery + this.calculate(); + if (json.street) { // Received street property @@ -555,7 +612,7 @@ core.modules.connect("damper").then(() => { */ damper: core.damper( (...variables) => delivery.write.system(...variables), - 1200, + 400, 3, ), }, @@ -576,7 +633,7 @@ core.modules.connect("damper").then(() => { */ damper: core.damper( (...variables) => delivery.calculate.system(...variables), - 300, + 200, ), }, ); diff --git a/mirzaev/arming_bot/system/public/themes/default/css/animations.css b/mirzaev/arming_bot/system/public/themes/default/css/animations.css new file mode 100644 index 0000000..7942108 --- /dev/null +++ b/mirzaev/arming_bot/system/public/themes/default/css/animations.css @@ -0,0 +1,20 @@ +@charset "UTF-8"; + +@keyframes slide-down-revert { + 0% { + transform: translate(0, 0%); + clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%); + } + + 100% { + transform: translate(0, -100%); + clip-path: polygon(0% 100%, 100% 100%, 100% 200%, 0% 200%); + } +} + +.slide.down.revert.animated { + animation-duration: var(--animation-duration, 0.2s); + animation-name: slide-down-revert; + animation-fill-mode: forwards; + animation-timing-function: cubic-bezier(1, 0, 1, 1); +} diff --git a/mirzaev/arming_bot/system/public/themes/default/css/cart.css b/mirzaev/arming_bot/system/public/themes/default/css/cart.css index 029dd0d..d68f3ea 100755 --- a/mirzaev/arming_bot/system/public/themes/default/css/cart.css +++ b/mirzaev/arming_bot/system/public/themes/default/css/cart.css @@ -1,15 +1,18 @@ @charset "UTF-8"; -main>section:is(#summary, #products, #delivery) { +main>section:is(#summary, #products, #delivery, #delivery_request) { width: var(--width); gap: var(--gap); overflow: hidden; } +main>section:is(#summary, #delivery) { + background-color: var(--tg-theme-section-bg-color); +} + main>section#delivery>div.column { padding: 1rem; gap: var(--gap); - background-color: var(--tg-theme-section-bg-color); } main>section#delivery>div.column>div#deliveries>input { @@ -70,16 +73,41 @@ main:has(section#summary.disabled:hover)>section#delivery>div { filter: brightness(1.2); } +section#delivery>div.column>div#deliveries>input:not(:checked)+section#delivery_request { + display: inline-flex; +} + +main>section#delivery_request>p:only-of-type { + margin: unset; + width: 100%; + height: 1rem; + display: inline-flex; + align-items: center; + padding: 0 1rem; +} + +main>section#delivery_request>p:only-of-type>i.icon { + /* color: var(--tg-theme-accent-text-color); */ + color: var(--tg-theme-text-color); +} + +main>section#delivery_request>p:only-of-type>span:only-of-type { + margin: 0 auto; + /* color: var(--tg-theme-accent-text-color); */ + color: var(--tg-theme-text-color); + color: var(--tg-theme-hint-color); +} + main>section#summary>div { container-type: inline-size; container-name: summary; + height: 2rem; padding-left: 1rem; align-items: center; gap: 0.4rem; overflow: hidden; pointer-events: auto; border-radius: 1.375rem; - background-color: var(--tg-theme-section-bg-color); } main>section#summary>div>span { @@ -104,14 +132,15 @@ main>section#summary>div>button#order * { main>section#summary.disabled, main>section#summary>div:has(button#order:disabled), main:not(:has(section#delivery>div.column>div#deliveries>input:checked))>section#summary>div:has(button#order:enabled) { - cursor: not-allowed; + /* cursor: not-allowed; */ } main>section#summary.disabled, main>section#summary>div>button#order:disabled, main:not(:has(section#delivery>div.column>div#deliveries>input:checked))>section#summary>div>button#order:enabled { - pointer-events: none; - filter: grayscale(1); + /* pointer-events: none; + filter: grayscale(1); */ + display: none; } main>section#products>article.product { diff --git a/mirzaev/arming_bot/system/public/themes/default/css/icons/pin.css b/mirzaev/arming_bot/system/public/themes/default/css/icons/pin.css new file mode 100755 index 0000000..2f5a0f6 --- /dev/null +++ b/mirzaev/arming_bot/system/public/themes/default/css/icons/pin.css @@ -0,0 +1,38 @@ +@charset "UTF-8"; + +i.icon.pin { + box-sizing: border-box; + position: relative; + margin-top: -4px; + width: 18px; + height: 18px; + display: block; + border: 2px solid; + border-radius: 100% 100% 0 100%; + transform: rotate(45deg); +} + +i.icon.pin.small { + width: 15px; + height: 15px; +} + +i.icon.pin::before { + content: ""; + position: absolute; + left: 3px; + top: 3px; + width: 8px; + height: 8px; + display: block; + box-sizing: border-box; + border: 2px solid; + border-radius: 40px; +} + +i.icon.pin.small::before { + top: 2px; + left: 2px; + width: 7px; + height: 7px; +} diff --git a/mirzaev/arming_bot/system/public/themes/default/css/main.css b/mirzaev/arming_bot/system/public/themes/default/css/main.css index 0dd3430..622be88 100755 --- a/mirzaev/arming_bot/system/public/themes/default/css/main.css +++ b/mirzaev/arming_bot/system/public/themes/default/css/main.css @@ -66,10 +66,14 @@ main { display: flex; flex-direction: column; align-items: center; - gap: 26px; + gap: calc(var(--gap) + 10px); transition: 0s; } +main > *.merged { + margin-top: -14px; +} + main>*[data-section] { width: var(--width); } @@ -261,6 +265,10 @@ input { border-radius: 0.75rem; } +.rounded.smoother { + border-radius: 1.375rem; +} + .row { display: flex; flex-direction: row; @@ -284,6 +292,10 @@ input { color: var(--tg-theme-hint-color); } +.deleted { + display: none; +} + .unselectable { -webkit-touch-callout: none; -webkit-user-select: none; diff --git a/mirzaev/arming_bot/system/views/themes/default/cart/elements/delivery.html b/mirzaev/arming_bot/system/views/themes/default/cart/elements/delivery.html index e4d60b6..b225c7b 100755 --- a/mirzaev/arming_bot/system/views/themes/default/cart/elements/delivery.html +++ b/mirzaev/arming_bot/system/views/themes/default/cart/elements/delivery.html @@ -14,7 +14,12 @@
+
+

+ + {{ language.name == 'ru' ? 'Укажите данные для доставки' : 'Enter delivery information' }} +

+
{% endif %} diff --git a/mirzaev/arming_bot/system/views/themes/default/cart/elements/summary.html b/mirzaev/arming_bot/system/views/themes/default/cart/elements/summary.html index 3f1a5c0..10bacdc 100755 --- a/mirzaev/arming_bot/system/views/themes/default/cart/elements/summary.html +++ b/mirzaev/arming_bot/system/views/themes/default/cart/elements/summary.html @@ -1,6 +1,6 @@ {% if cart.products is not empty %}
+ class="rounded column unselectable">
{{ cart.summary.amount ?? 0 }} {{ language.name == "ru" ? "товаров на сумму" : "products worth" }} @@ -12,8 +12,7 @@ {{ session.buffer.delivery[account.buffer.delivery.company ?? session.buffer.delivery.company].days }} {% endif %}
diff --git a/mirzaev/arming_bot/system/views/themes/default/cart/page.html b/mirzaev/arming_bot/system/views/themes/default/cart/page.html index 6dc994a..0b496a0 100755 --- a/mirzaev/arming_bot/system/views/themes/default/cart/page.html +++ b/mirzaev/arming_bot/system/views/themes/default/cart/page.html @@ -9,6 +9,7 @@ + {% endblock %} {% block main %} diff --git a/mirzaev/arming_bot/system/views/themes/default/head.html b/mirzaev/arming_bot/system/views/themes/default/head.html index 05e047b..8920a9b 100755 --- a/mirzaev/arming_bot/system/views/themes/default/head.html +++ b/mirzaev/arming_bot/system/views/themes/default/head.html @@ -24,4 +24,5 @@ --days-short: "{{ language.name == 'ru' ? 'дн' : 'd' }}"; } + {% endblock %}