<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<div class="page" data-name="trackinginfo">

    <div class="navbar">
        <div class="navbar-bg"></div>
        <div class="navbar-inner">
            <div class="left">
                <a href="#" class="link icon-only back">
                    <i class="icon icon-back"></i>
                </a>
            </div>
            <div class="title">Tracking Status</div>
            <div class="right">
                <a class="link" onclick="openTrackingHistory()">
                    <i class="material-icons">refresh</i>
                </a>
            </div>
        </div>
    </div>

    <div class="page-content">
        <div class="row justify-content-center">
            <div class="col-100 medium-60 large-50 xlarge-40 elevation-tablet margin-top-tablet">
                <div class="list media-list no-hairlines tablet-inset no-margin-top">
                    <ul>
                        <li class="item-divider">Information</li>
                        <li>
                            <div class="item-content">
                                <div class="item-inner">
                                    {{#with current}}
                                    <div class="item-title-row">
                                        <div class="item-title">{{status}}</div>
                                        <div class="item-after">{{date}}</div>
                                    </div>
                                    <div class="item-text">{{details}}</div>
                                    <div class="item-text"><b>{{location.display}}</b></div>
                                    {{/with}}
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-text">Tracking Code: {{code}}</div>
                                    <div class="item-text">Carrier: {{carrier.name}}</div>
                                    {{#if service.name}}<div class="item-text">Service: {{service.name}}</div>{{/if}}
                                    <div class="item-text">From: {{addresses.from}}</div>
                                    <div class="item-text">To: {{addresses.to}}</div>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="item-content bg-color-white" style="display: flex; justify-content: center; padding-left: 1rem; padding-right: 1rem;">
                                <svg class="barcode" id="trackingbarcode"></svg>
                            </div>
                        </li>
                        <li class="item-divider">History</li>
                        {{#each history}}
                        <li>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-title-row">
                                        <div class="item-title">{{status}}</div>
                                        <div class="item-after">{{date}}</div>
                                    </div>
                                    <div class="item-text">{{details}}</div>
                                    <div class="item-text"><b>{{location.display}}</b></div>
                                </div>
                            </div>
                        </li>
                        {{else}}
                        <li class="item-content">
                            No item history found.
                        </li>
                        {{/each}}
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <script>
        JsBarcode("#trackingbarcode", "{{#if barcode}}{{escape barcode}}{{else}}{{escape code}}{{/if}}", {
            format: "code128",
            ean128: true,
            width: 2,
            height: 40
        });
    </script>
</div>