Skip to content

Commit

Permalink
feat: add identifier field to location
Browse files Browse the repository at this point in the history
Signed-off-by: vanpho93 <[email protected]>
  • Loading branch information
vanpho93 committed Mar 16, 2023
1 parent 08c4271 commit 7d4dd54
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test("throws if shop not found", async () => {
test("create location and returns the result", async () => {
const location = {
shopId: "123",
identifier: "test-location",
name: "Test location",
type: "marketplace",
address: {
Expand Down
6 changes: 5 additions & 1 deletion packages/api-plugin-location/src/queries/locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ export default async function locations(context, shopId, filter) {
const selector = { shopId };

if (filter) {
const { name, type, phone, fulfillmentMethod, localFulfillmentOnly, enabled, isArchived } = filter;
const { name, identifier, type, phone, fulfillmentMethod, localFulfillmentOnly, enabled, isArchived } = filter;

if (name) {
selector.name = name;
}

if (identifier) {
selector.identifier = identifier;
}

if (type) {
selector.type = type;
}
Expand Down
12 changes: 12 additions & 0 deletions packages/api-plugin-location/src/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type Location {
" The name of the location."
name: String!

" The other identifier of the location."
identifier: String!

" The type of the location [warehouse, store, dropship, marketplace]."
type: String!

Expand Down Expand Up @@ -102,6 +105,9 @@ input LocationFilter {
" The name of the location."
name: String

" The other identifier of the location."
identifier: String

" The type of the location [warehouse, store, dropship, marketplace]."
type: String

Expand Down Expand Up @@ -149,6 +155,9 @@ input LocationCreateInput {
" The name of the location."
name: String!

" The other identifier of the location."
identifier: String!

" The type of the location [warehouse, store, dropship, marketplace]."
type: String!

Expand Down Expand Up @@ -183,6 +192,9 @@ input LocationUpdateInput {

" The shop ID"
shopId: ID!

" The other identifier of the location."
identifier: String

" The shop ID"
name: String
Expand Down
76 changes: 69 additions & 7 deletions packages/api-plugin-location/src/simpleSchemas.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,74 @@
import SimpleSchema from "simpl-schema";
import CountryDefinitions from "@reactioncommerce/api-utils/CountryDefinitions.js";

const withoutCodeCountries = ["AO", "AG", "AW", "BS", "BZ", "BJ", "BW",
"BF", "BI", "CM", "CF", "KM", "CG", "CD", "CK", "CI", "DJ",
"DM", "GQ", "ER", "FJ", "TF", "GM", "GH", "GD", "GN", "GY",
"HK", "IE", "JM", "KE", "KI", "MO", "MW", "ML", "MR", "MU",
"MS", "NR", "AN", "NU", "KP", "PA", "QA", "RW", "KN", "LC",
"ST", "SA", "SC", "SL", "SB", "SO", "SR", "SY", "TZ", "TL",
"TK", "TO", "TT", "TV", "UG", "AE", "VU", "YE", "ZW"];
const withoutCodeCountries = [
"AO",
"AG",
"AW",
"BS",
"BZ",
"BJ",
"BW",
"BF",
"BI",
"CM",
"CF",
"KM",
"CG",
"CD",
"CK",
"CI",
"DJ",
"DM",
"GQ",
"ER",
"FJ",
"TF",
"GM",
"GH",
"GD",
"GN",
"GY",
"HK",
"IE",
"JM",
"KE",
"KI",
"MO",
"MW",
"ML",
"MR",
"MU",
"MS",
"NR",
"AN",
"NU",
"KP",
"PA",
"QA",
"RW",
"KN",
"LC",
"ST",
"SA",
"SC",
"SL",
"SB",
"SO",
"SR",
"SY",
"TZ",
"TL",
"TK",
"TO",
"TT",
"TV",
"UG",
"AE",
"VU",
"YE",
"ZW"
];

export const LocationAddress = new SimpleSchema({
address1: {
Expand Down Expand Up @@ -51,6 +112,7 @@ export const Location = new SimpleSchema({
_id: String,
shopId: String,
name: String,
identifier: String,
type: {
type: String,
allowedValues: ["warehouse", "store", "dropship", "marketplace"]
Expand Down

0 comments on commit 7d4dd54

Please sign in to comment.