Browse Source

feat(admin-ui): Display warnings if Channel lacks default zones

Relates to #323
Michael Bromley 5 years ago
parent
commit
e80fcf8b52

+ 18 - 1
packages/admin-ui/src/lib/settings/src/components/channel-detail/channel-detail.component.html

@@ -50,7 +50,9 @@
             formControlName="defaultLanguageCode"
             [vdrDisabled]="!('SuperAdmin' | hasPermission)"
         >
-            <option *ngFor="let languageCode of availableLanguageCodes$ | async" [value]="languageCode">{{ 'lang.' + languageCode | translate }} ({{ languageCode | uppercase }})</option>
+            <option *ngFor="let languageCode of availableLanguageCodes$ | async" [value]="languageCode"
+                >{{ 'lang.' + languageCode | translate }} ({{ languageCode | uppercase }})</option
+            >
         </select>
     </vdr-form-field>
     <vdr-form-field [label]="'settings.prices-include-tax' | translate" for="pricesIncludeTax">
@@ -74,6 +76,14 @@
             <option *ngFor="let zone of zones$ | async" [value]="zone.id">{{ zone.name }}</option>
         </select>
     </vdr-form-field>
+    <clr-alert *ngIf="detailForm.value.code && !detailForm.value.defaultTaxZoneId" clrAlertType="danger" [clrAlertClosable]="false">
+        <clr-alert-item>
+            <span class="alert-text">
+                {{ 'error.no-default-tax-zone-set' | translate }}
+            </span>
+        </clr-alert-item>
+    </clr-alert>
+
     <vdr-form-field [label]="'settings.default-shipping-zone' | translate" for="defaultShippingZoneId">
         <select
             clrSelect
@@ -84,4 +94,11 @@
             <option *ngFor="let zone of zones$ | async" [value]="zone.id">{{ zone.name }}</option>
         </select>
     </vdr-form-field>
+    <clr-alert *ngIf="detailForm.value.code && !detailForm.value.defaultShippingZoneId" clrAlertType="warning" [clrAlertClosable]="false">
+        <clr-alert-item>
+            <span class="alert-text">
+                {{ 'error.no-default-shipping-zone-set' | translate }}
+            </span>
+        </clr-alert-item>
+    </clr-alert>
 </form>

+ 4 - 0
packages/admin-ui/src/lib/settings/src/components/channel-detail/channel-detail.component.scss

@@ -0,0 +1,4 @@
+clr-alert {
+    max-width: 30rem;
+    margin-bottom: 12px;
+}

+ 2 - 0
packages/admin-ui/src/lib/static/i18n-messages/en.json

@@ -267,6 +267,8 @@
     "403-forbidden": "You are not currently authorized to access \"{ path }\". Either you lack permissions, or your session has expired.",
     "could-not-connect-to-server": "Could not connect to the Vendure server at { url }",
     "facet-value-form-values-do-not-match": "The number of values in the facet form does not match the actual number of values",
+    "no-default-shipping-zone-set": "This channel has no default shipping zone. This may cause errors when calculating order shipping charges.",
+    "no-default-tax-zone-set": "This channel has no default tax zone, which will cause errors when calculating prices. Please create or select a zone.",
     "product-variant-form-values-do-not-match": "The number of variants in the product form does not match the actual number of variants"
   },
   "lang": {