-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Admin): Add address validation to admin pages
Adds address autocomplete to: - Customer page - Create new customer - Orders page - Create new order - Edit existing order
- Loading branch information
Showing
9 changed files
with
95 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { setupBind } from "@ideal-postcodes/jsutil"; | ||
|
||
import { Config, setupAutocomplete } from "./extension"; | ||
|
||
import { selectors } from "./billing"; | ||
|
||
const parentScope = "fieldset"; | ||
const parentTest = (e: HTMLElement) => e.className === "admin__fieldset"; | ||
|
||
const bind = (config: Config) => { | ||
setupBind({ selectors, parentScope, parentTest }).forEach(({ targets }) => { | ||
console.log(selectors); | ||
setupAutocomplete(config, targets); | ||
}); | ||
}; | ||
|
||
const pageTest = () => window.location.pathname.includes("/customer"); | ||
|
||
export const bindings = { bind, pageTest }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { setupBind } from "@ideal-postcodes/jsutil"; | ||
|
||
import { Config, setupAutocomplete } from "./extension"; | ||
|
||
export const billing = { | ||
line_1: '[name="order[billing_address][street][0]"]', | ||
line_2: '[name="order[billing_address][street][1]"]', | ||
line_3: '[name="order[billing_address][street][2]"]', | ||
postcode: '[name="order[billing_address][postcode]"]', | ||
post_town: '[name="order[billing_address][city]"]', | ||
organisation: '[name="order[billing_address][company]"]', | ||
county: '[name="order[billing_address][region_id]"]', | ||
country: '[name="order[billing_address][country_id]"]' | ||
}; | ||
|
||
export const shipping = { | ||
line_1: '[name="order[shipping_address][street][0]"]', | ||
line_2: '[name="order[shipping_address][street][1]"]', | ||
line_3: '[name="order[shipping_address][street][2]"]', | ||
postcode: '[name="order[shipping_address][postcode]"]', | ||
post_town: '[name="order[shipping_address][city]"]', | ||
organisation: '[name="order[shipping_address][company]"]', | ||
county: '[name="order[shipping_address][region_id]"]', | ||
country: '[name="order[shipping_address][country_id]"]' | ||
}; | ||
|
||
const selectorList = [billing, shipping]; | ||
|
||
const parentScope = "fieldset"; | ||
|
||
const bind = (config: Config) => { | ||
selectorList.forEach(selectors => { | ||
setupBind({ selectors, parentScope }).forEach(({ targets }) => { | ||
setupAutocomplete(config, targets); | ||
}); | ||
}); | ||
}; | ||
|
||
const pageTest = () => window.location.pathname.includes("/sales"); | ||
|
||
export const bindings = { bind, pageTest }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { bindings as b } from "./multishipping"; | ||
const { bind } = b; | ||
|
||
const pageTest = () => window.location.pathname.includes("/customer/address"); | ||
|
||
export const bindings = { bind, pageTest }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.