Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Currency and Email Address from Stores Address Form #112

Merged
merged 4 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 63 additions & 20 deletions src/OnboardingSPA/pages/Steps/Ecommerce/StepAddress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import NewfoldLargeCard from '../../../../components/NewfoldLargeCard';
import { store as nfdOnboardingStore } from '../../../../store';
import content from '../content.json';
import countries from '../countries.json';
import currencies from '../currencies.json';
import { useWPSettings } from '../useWPSettings';

const StepAddress = () => {
const isLargeViewport = useViewportMatch( 'medium' );
const isLargeViewport = useViewportMatch('medium');
const {
setDrawerActiveView,
setIsDrawerOpened,
Expand Down Expand Up @@ -44,7 +45,9 @@ const StepAddress = () => {
'woocommerce_store_address',
'woocommerce_store_city',
'woocommerce_store_postcode',
'woocommerce_default_country'
'woocommerce_default_country',
'woocommerce_currency',
'woocommerce_email_from_address',
];
if (settings !== null && currentData.storeDetails.address === undefined) {
setCurrentOnboardingData({
Expand Down Expand Up @@ -84,8 +87,8 @@ const StepAddress = () => {
if (country === defaultCountry && state === undefined) {
state = defaultState;
}
if ( states.length == 0 ) {
state = "" // edge case to handle when the user goes back to onboarding and changes from a country with state to no state
if (states.length == 0) {
state = ''; // edge case to handle when the user goes back to onboarding and changes from a country with state to no state
}
let place = '';
if (['country', 'state'].includes(fieldName)) {
Expand Down Expand Up @@ -133,6 +136,7 @@ const StepAddress = () => {
// );
navigate('/ecommerce/step/tax');
}}
style={{ display: 'grid', justifyItems: 'center' }}
>
<div className='nfd-card-heading center onboarding-ecommerce-step'>
<CardHeader
Expand All @@ -145,8 +149,8 @@ const StepAddress = () => {
{settings === null && <p>Loading your details...</p>}
</div>
<div className='store-address-form'>
<div>
<label data-required>
<div data-name='country'>
<label aria-required>
{__('Where is your store based?', 'wp-module-onboarding')}
</label>
{settings === null ? (
Expand All @@ -167,8 +171,8 @@ const StepAddress = () => {
</select>
)}
</div>
<div>
<label data-required>
<div data-name='woocommerce_store_address'>
<label aria-required>
{__('Address', 'wp-module-onboarding')}
</label>
<input
Expand All @@ -179,9 +183,12 @@ const StepAddress = () => {
{...fieldProps}
/>
</div>
<div className='sm:col-layout md:row-layout full-address-fields' style={{"--fields":`${states.length === 0 || settings === null ? 2 : 3}`}}>
<div>
<label data-required>
<div
data-name='full-address'
data-state-empty={states.length === 0}
>
<div data-name='woocommerce_store_city'>
<label aria-required>
{__('City', 'wp-module-onboarding')}
</label>
<input
Expand All @@ -193,28 +200,30 @@ const StepAddress = () => {
/>
</div>
{states.length === 0 || settings === null ? null : (
<div>
<label data-required>
{__('State', 'wp-module-onboarding')}
</label>
<div data-name='state'>
<label aria-required>
{__('State', 'wp-module-onboarding')}
</label>
<select
type='text'
name='state'
required
defaultValue={selectedCountry==defaultCountry?defaultState:""}
defaultValue={
selectedCountry == defaultCountry ? defaultState : ''
}
{...fieldProps}
>
<option key={""} value={""} selected />
<option key={''} value={''} selected />
{states.map((state) => (
<option key={state.code} value={state.code}>
{state.name}
</option>
))}
</select>
</div>
</div>
)}
<div>
<label data-required>
<div data-name='woocommerce_store_postcode'>
<label aria-required>
{__('Postal Code', 'wp-module-onboarding')}
</label>
<input
Expand All @@ -226,6 +235,40 @@ const StepAddress = () => {
/>
</div>
</div>
<div>
<label aria-required>
{__('Email', 'wp-module-onboarding')}
</label>
<input
name='woocommerce_email_from_address'
type='email'
required
defaultValue={address?.woocommerce_email_from_address}
{...fieldProps}
/>
</div>
<div>
<label>
{__(
'What currency do you want to display in your store?',
'wp-module-onboarding'
)}
</label>
<select
type='text'
name='woocommerce_currency'
value={address?.woocommerce_currency}
{...fieldProps}
>
{Object.entries(currencies).map(([code, currency]) => (
<option
key={code}
value={code}
dangerouslySetInnerHTML={{ __html: currency }}
/>
))}
</select>
</div>
<em style={{ display: 'inline' }}>* required</em>
</div>
<button
Expand Down
165 changes: 165 additions & 0 deletions src/OnboardingSPA/pages/Steps/Ecommerce/currencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"AED": "United Arab Emirates dirham (AED) (&#x62f;.&#x625;)",
"AFN": "Afghan afghani (AFN) (&#x60b;)",
"ALL": "Albanian lek (ALL) (L)",
"AMD": "Armenian dram (AMD) (AMD)",
"ANG": "Netherlands Antillean guilder (ANG) (&fnof;)",
"AOA": "Angolan kwanza (AOA) (Kz)",
"ARS": "Argentine peso (ARS) (&#36;)",
"AUD": "Australian dollar (AUD) (&#36;)",
"AWG": "Aruban florin (AWG) (Afl.)",
"AZN": "Azerbaijani manat (AZN) (AZN)",
"BAM": "Bosnia and Herzegovina convertible mark (BAM) (KM)",
"BBD": "Barbadian dollar (BBD) (&#36;)",
"BDT": "Bangladeshi taka (BDT) (&#2547;&nbsp;)",
"BGN": "Bulgarian lev (BGN) (&#1083;&#1074;.)",
"BHD": "Bahraini dinar (BHD) (.&#x62f;.&#x628;)",
"BIF": "Burundian franc (BIF) (Fr)",
"BMD": "Bermudian dollar (BMD) (&#36;)",
"BND": "Brunei dollar (BND) (&#36;)",
"BOB": "Bolivian boliviano (BOB) (Bs.)",
"BRL": "Brazilian real (BRL) (&#82;&#36;)",
"BSD": "Bahamian dollar (BSD) (&#36;)",
"BTC": "Bitcoin (BTC) (&#3647;)",
"BTN": "Bhutanese ngultrum (BTN) (Nu.)",
"BWP": "Botswana pula (BWP) (P)",
"BYR": "Belarusian ruble (old) (BYR) (Br)",
"BYN": "Belarusian ruble (BYN) (Br)",
"BZD": "Belize dollar (BZD) (&#36;)",
"CAD": "Canadian dollar (CAD) (&#36;)",
"CDF": "Congolese franc (CDF) (Fr)",
"CHF": "Swiss franc (CHF) (&#67;&#72;&#70;)",
"CLP": "Chilean peso (CLP) (&#36;)",
"CNY": "Chinese yuan (CNY) (&yen;)",
"COP": "Colombian peso (COP) (&#36;)",
"CRC": "Costa Rican col&oacute;n (CRC) (&#x20a1;)",
"CUC": "Cuban convertible peso (CUC) (&#36;)",
"CUP": "Cuban peso (CUP) (&#36;)",
"CVE": "Cape Verdean escudo (CVE) (&#36;)",
"CZK": "Czech koruna (CZK) (&#75;&#269;)",
"DJF": "Djiboutian franc (DJF) (Fr)",
"DKK": "Danish krone (DKK) (kr.)",
"DOP": "Dominican peso (DOP) (RD&#36;)",
"DZD": "Algerian dinar (DZD) (&#x62f;.&#x62c;)",
"EGP": "Egyptian pound (EGP) (EGP)",
"ERN": "Eritrean nakfa (ERN) (Nfk)",
"ETB": "Ethiopian birr (ETB) (Br)",
"EUR": "Euro (EUR) (&euro;)",
"FJD": "Fijian dollar (FJD) (&#36;)",
"FKP": "Falkland Islands pound (FKP) (&pound;)",
"GBP": "Pound sterling (GBP) (&pound;)",
"GEL": "Georgian lari (GEL) (&#x20be;)",
"GGP": "Guernsey pound (GGP) (&pound;)",
"GHS": "Ghana cedi (GHS) (&#x20b5;)",
"GIP": "Gibraltar pound (GIP) (&pound;)",
"GMD": "Gambian dalasi (GMD) (D)",
"GNF": "Guinean franc (GNF) (Fr)",
"GTQ": "Guatemalan quetzal (GTQ) (Q)",
"GYD": "Guyanese dollar (GYD) (&#36;)",
"HKD": "Hong Kong dollar (HKD) (&#36;)",
"HNL": "Honduran lempira (HNL) (L)",
"HRK": "Croatian kuna (HRK) (kn)",
"HTG": "Haitian gourde (HTG) (G)",
"HUF": "Hungarian forint (HUF) (&#70;&#116;)",
"IDR": "Indonesian rupiah (IDR) (Rp)",
"ILS": "Israeli new shekel (ILS) (&#8362;)",
"IMP": "Manx pound (IMP) (&pound;)",
"INR": "Indian rupee (INR) (&#8377;)",
"IQD": "Iraqi dinar (IQD) (&#x62f;.&#x639;)",
"IRR": "Iranian rial (IRR) (&#xfdfc;)",
"IRT": "Iranian toman (IRT) (&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;)",
"ISK": "Icelandic kr&oacute;na (ISK) (kr.)",
"JEP": "Jersey pound (JEP) (&pound;)",
"JMD": "Jamaican dollar (JMD) (&#36;)",
"JOD": "Jordanian dinar (JOD) (&#x62f;.&#x627;)",
"JPY": "Japanese yen (JPY) (&yen;)",
"KES": "Kenyan shilling (KES) (KSh)",
"KGS": "Kyrgyzstani som (KGS) (&#x441;&#x43e;&#x43c;)",
"KHR": "Cambodian riel (KHR) (&#x17db;)",
"KMF": "Comorian franc (KMF) (Fr)",
"KPW": "North Korean won (KPW) (&#x20a9;)",
"KRW": "South Korean won (KRW) (&#8361;)",
"KWD": "Kuwaiti dinar (KWD) (&#x62f;.&#x643;)",
"KYD": "Cayman Islands dollar (KYD) (&#36;)",
"KZT": "Kazakhstani tenge (KZT) (&#8376;)",
"LAK": "Lao kip (LAK) (&#8365;)",
"LBP": "Lebanese pound (LBP) (&#x644;.&#x644;)",
"LKR": "Sri Lankan rupee (LKR) (&#xdbb;&#xdd4;)",
"LRD": "Liberian dollar (LRD) (&#36;)",
"LSL": "Lesotho loti (LSL) (L)",
"LYD": "Libyan dinar (LYD) (&#x644;.&#x62f;)",
"MAD": "Moroccan dirham (MAD) (&#x62f;.&#x645;.)",
"MDL": "Moldovan leu (MDL) (MDL)",
"MGA": "Malagasy ariary (MGA) (Ar)",
"MKD": "Macedonian denar (MKD) (&#x434;&#x435;&#x43d;)",
"MMK": "Burmese kyat (MMK) (Ks)",
"MNT": "Mongolian t&ouml;gr&ouml;g (MNT) (&#x20ae;)",
"MOP": "Macanese pataca (MOP) (P)",
"MRU": "Mauritanian ouguiya (MRU) (UM)",
"MUR": "Mauritian rupee (MUR) (&#x20a8;)",
"MVR": "Maldivian rufiyaa (MVR) (.&#x783;)",
"MWK": "Malawian kwacha (MWK) (MK)",
"MXN": "Mexican peso (MXN) (&#36;)",
"MYR": "Malaysian ringgit (MYR) (&#82;&#77;)",
"MZN": "Mozambican metical (MZN) (MT)",
"NAD": "Namibian dollar (NAD) (N&#36;)",
"NGN": "Nigerian naira (NGN) (&#8358;)",
"NIO": "Nicaraguan c&oacute;rdoba (NIO) (C&#36;)",
"NOK": "Norwegian krone (NOK) (&#107;&#114;)",
"NPR": "Nepalese rupee (NPR) (&#8360;)",
"NZD": "New Zealand dollar (NZD) (&#36;)",
"OMR": "Omani rial (OMR) (&#x631;.&#x639;.)",
"PAB": "Panamanian balboa (PAB) (B/.)",
"PEN": "Sol (PEN) (S/)",
"PGK": "Papua New Guinean kina (PGK) (K)",
"PHP": "Philippine peso (PHP) (&#8369;)",
"PKR": "Pakistani rupee (PKR) (&#8360;)",
"PLN": "Polish z&#x142;oty (PLN) (&#122;&#322;)",
"PRB": "Transnistrian ruble (PRB) (&#x440;.)",
"PYG": "Paraguayan guaran&iacute; (PYG) (&#8370;)",
"QAR": "Qatari riyal (QAR) (&#x631;.&#x642;)",
"RON": "Romanian leu (RON) (lei)",
"RSD": "Serbian dinar (RSD) (&#1088;&#1089;&#1076;)",
"RUB": "Russian ruble (RUB) (&#8381;)",
"RWF": "Rwandan franc (RWF) (Fr)",
"SAR": "Saudi riyal (SAR) (&#x631;.&#x633;)",
"SBD": "Solomon Islands dollar (SBD) (&#36;)",
"SCR": "Seychellois rupee (SCR) (&#x20a8;)",
"SDG": "Sudanese pound (SDG) (&#x62c;.&#x633;.)",
"SEK": "Swedish krona (SEK) (&#107;&#114;)",
"SGD": "Singapore dollar (SGD) (&#36;)",
"SHP": "Saint Helena pound (SHP) (&pound;)",
"SLL": "Sierra Leonean leone (SLL) (Le)",
"SOS": "Somali shilling (SOS) (Sh)",
"SRD": "Surinamese dollar (SRD) (&#36;)",
"SSP": "South Sudanese pound (SSP) (&pound;)",
"STN": "S&atilde;o Tom&eacute; and Pr&iacute;ncipe dobra (STN) (Db)",
"SYP": "Syrian pound (SYP) (&#x644;.&#x633;)",
"SZL": "Swazi lilangeni (SZL) (E)",
"THB": "Thai baht (THB) (&#3647;)",
"TJS": "Tajikistani somoni (TJS) (&#x405;&#x41c;)",
"TMT": "Turkmenistan manat (TMT) (m)",
"TND": "Tunisian dinar (TND) (&#x62f;.&#x62a;)",
"TOP": "Tongan pa&#x2bb;anga (TOP) (T&#36;)",
"TRY": "Turkish lira (TRY) (&#8378;)",
"TTD": "Trinidad and Tobago dollar (TTD) (&#36;)",
"TWD": "New Taiwan dollar (TWD) (&#78;&#84;&#36;)",
"TZS": "Tanzanian shilling (TZS) (Sh)",
"UAH": "Ukrainian hryvnia (UAH) (&#8372;)",
"UGX": "Ugandan shilling (UGX) (UGX)",
"USD": "United States (US) dollar (USD) (&#36;)",
"UYU": "Uruguayan peso (UYU) (&#36;)",
"UZS": "Uzbekistani som (UZS) (UZS)",
"VEF": "Venezuelan bol&iacute;var (VEF) (Bs F)",
"VES": "Bol&iacute;var soberano (VES) (Bs.S)",
"VND": "Vietnamese &#x111;&#x1ed3;ng (VND) (&#8363;)",
"VUV": "Vanuatu vatu (VUV) (Vt)",
"WST": "Samoan t&#x101;l&#x101; (WST) (T)",
"XAF": "Central African CFA franc (XAF) (CFA)",
"XCD": "East Caribbean dollar (XCD) (&#36;)",
"XOF": "West African CFA franc (XOF) (CFA)",
"XPF": "CFP franc (XPF) (Fr)",
"YER": "Yemeni rial (YER) (&#xfdfc;)",
"ZAR": "South African rand (ZAR) (&#82;)",
"ZMW": "Zambian kwacha (ZMW) (ZK)"
}
Loading