-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vue-demo): create state and country component (#270)
- Loading branch information
1 parent
e6a52ec
commit 14d97c5
Showing
15 changed files
with
180 additions
and
115 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,5 @@ | ||
--- | ||
"vue-demo-store": minor | ||
--- | ||
|
||
Add state to the address forms |
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,5 @@ | ||
--- | ||
"@shopware-pwa/api-client": patch | ||
--- | ||
|
||
Change getContextCountryEndpoint request type to POST |
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
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
Empty file.
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
97 changes: 97 additions & 0 deletions
97
templates/vue-demo-store/components/shared/SharedCountryStateInput.vue
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,97 @@ | ||
<script lang="ts" setup> | ||
const emit = defineEmits<{ | ||
(e: "update:countryId", value: string): void; | ||
(e: "update:stateId", value: string): void; | ||
}>(); | ||
const props = withDefaults( | ||
defineProps<{ | ||
countryId: string; | ||
stateId: string | null; | ||
countryIdValidation?: object | null; | ||
stateIdValidation?: object | null; | ||
}>(), | ||
{ | ||
countryId: "", | ||
stateId: "", | ||
countryIdValidation: null, | ||
stateIdValidation: null, | ||
} | ||
); | ||
const { countryId, stateId } = useVModels(props, emit); | ||
const { getCountries, getStatesForCountry } = useCountries(); | ||
const states = computed(() => { | ||
return getStatesForCountry(countryId.value); | ||
}); | ||
function onCountrySelectChanged() { | ||
stateId.value = ""; | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="flex gap-6"> | ||
<div class="w-full"> | ||
<label for="country" class="block text-sm font-medium text-gray-700">{{ | ||
$t("form.country") | ||
}}</label> | ||
<select | ||
id="country" | ||
v-model="countryId" | ||
required | ||
name="country" | ||
autocomplete="country-name" | ||
class="mt-1 block w-full p-2.5 border border-gray-300 text-gray-900 text-sm rounded-md shadow-sm focus:ring-brand-light focus:border-brand-light" | ||
data-testid="country-select" | ||
@change="onCountrySelectChanged" | ||
@blur="countryIdValidation && countryIdValidation.$touch()" | ||
> | ||
<option disabled selected value=""> | ||
{{ $t("form.chooseCountry") }} | ||
</option> | ||
<option | ||
v-for="country in getCountries" | ||
:key="country.id" | ||
:value="country.id" | ||
> | ||
{{ country.name }} | ||
</option> | ||
</select> | ||
<span | ||
v-if="countryIdValidation && countryIdValidation.$error" | ||
class="pt-1 text-sm text-red-600 focus:ring-brand-primary border-gray-300" | ||
> | ||
{{ countryIdValidation.$errors[0].$message }} | ||
</span> | ||
</div> | ||
<div v-if="states && states.length" class="w-full"> | ||
<label for="state" class="block text-sm font-medium text-gray-700">{{ | ||
$t("form.state") | ||
}}</label> | ||
<select | ||
id="state" | ||
v-model="stateId" | ||
required | ||
name="state" | ||
autocomplete="state-name" | ||
class="mt-1 block w-full p-2.5 border border-gray-300 text-gray-900 text-sm rounded-md shadow-sm focus:ring-brand-light focus:border-brand-light" | ||
data-testid="checkout-pi-state-input" | ||
@blur="stateIdValidation && stateIdValidation.$touch()" | ||
> | ||
<option disabled selected value=""> | ||
{{ $t("form.chooseState") }} | ||
</option> | ||
|
||
<option v-for="state in states" :key="state.id" :value="state.id"> | ||
{{ state.name }} | ||
</option> | ||
</select> | ||
<span | ||
v-if="stateIdValidation && stateIdValidation.$error" | ||
class="pt-1 text-sm text-red-600 focus:ring-brand-primary border-gray-300" | ||
> | ||
{{ stateIdValidation.$errors[0].$message }} | ||
</span> | ||
</div> | ||
</div> | ||
</template> |
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.
14d97c5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
frontends-demo – ./templates/vue-demo-store
frontends-demo-git-main-shopware-frontends.vercel.app
frontends-demo-shopware-frontends.vercel.app
frontends-demo.vercel.app
14d97c5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shopware-frontends-docs – ./
frontends.shopware.com
shopware-frontends-docs-shopware-frontends.vercel.app
shopware-frontends-docs.vercel.app
shopware-frontends-docs-git-main-shopware-frontends.vercel.app