Skip to content

Commit

Permalink
Shipping setting returns error #479
Browse files Browse the repository at this point in the history
  • Loading branch information
treoden committed Apr 7, 2024
1 parent f2bb28d commit 42ee8cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Zone({ zone, countries, getZones }) {
</div>
<div className="flex-grow px-1">
<div>
<b>{zone.country.name}</b>
<b>{zone.country?.name || 'Worldwide'}</b>
</div>
<div>
{zone.provinces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ShippingZone {
shipping_zone_id: Int!
uuid: String!
name: String!
country: Country!
country: Country
provinces: [Province]
methods: [ShippingMethodByZone]
updateApi: String!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { select } = require('@evershop/postgres-query-builder');
const { contries } = require('@evershop/evershop/src/lib/locale/countries');
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
Expand Down Expand Up @@ -36,6 +37,18 @@ module.exports = {
const methods = await query.execute(pool);
return methods.map((row) => camelCase(row));
},
country: ({ country }) => {
if (!country) {
return null;
} else {
const c = contries.find((p) => p.code === country);
if (c) {
return c;
} else {
return null;
}
}
},
provinces: async ({ shippingZoneId }) => {
const provinces = await select('province')
.from('shipping_zone_province')
Expand Down

0 comments on commit 42ee8cb

Please sign in to comment.