Skip to content

Commit

Permalink
feat: create submission store
Browse files Browse the repository at this point in the history
Co-authored-by: Anissa Chadouli <[email protected]>
  • Loading branch information
theyokohamalife and Anissa3005 committed Dec 5, 2023
1 parent c25c0f2 commit 3ac3483
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 30 deletions.
43 changes: 34 additions & 9 deletions pages/submit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
type="text"
class="mb-5 px-3 py-3.5 w-[350px] h-[50px] bg-white rounded-lg border border-zinc-400 text-neutral-600 text-sm font-normal font-['Noto Sans JP']"
:placeholder="$t('submitPage.location')"
v-model="submissionStore.location"
/>
<span
class="mb-2 text-neutral-600 text-sm font-normal font-['Noto Sans JP']"
Expand All @@ -22,41 +23,65 @@
class="mb-5 mr-2 px-3 py-3.5 w-[170px] h-[50px] bg-white rounded-lg border border-zinc-400 text-neutral-600 text-sm font-normal font-['Noto Sans JP']"
type="text"
:placeholder="$t('submitPage.lastName')"
v-model="submissionStore.lastName"
/>
<input
class="mb-5 px-3 py-3.5 w-[170px] h-[50px] bg-white rounded-lg border border-zinc-400 text-neutral-600 text-sm font-normal font-['Noto Sans JP']"
type="text"
:placeholder="$t('submitPage.firstName')"
v-model="submissionStore.firstName"
/>
</div>
<span
class="mb-2 text-neutral-600 text-sm font-normal font-['Noto Sans JP']"
>{{ $t('submitPage.spokenLanguage1')}}</span>
<input
class="mb-5 px-3 py-3.5 w-[350px] h-[50px] bg-white rounded-lg border border-zinc-400"
type="text"
<select
class="mb-5 px-3 py-3.5 w-[350px] h-[50px] bg-white rounded-lg border border-zinc-400 text-primary-text"
:placeholder="$t('submitPage.selectLanguage1')"
/>
v-model="submissionStore.selectLanguage1"
>
<option
:key="index"
v-for="(locale, index) in localeStore.locales"
selected
:value="Object.keys(locale)[0]"
>{{ Object.values(locale)[0] }}</option>
</select>
<span
class="mb-2 text-neutral-600 text-sm font-normal font-['Noto Sans JP']"
>{{ $t('submitPage.spokenLanguage2')}}</span>
<input
class="mb-5 px-3 py-3.5 w-[350px] h-[50px] bg-white rounded-lg border border-zinc-400"
type="text"
<select
class="mb-5 px-3 py-3.5 w-[350px] h-[50px] bg-white rounded-lg border border-zinc-400 text-primary-text"
:placeholder="$t('submitPage.selectLanguage2')"
/>
v-model="submissionStore.selectLanguage2"
>
<option
:key="index"
v-for="(locale, index) in localeStore.locales"
selected
:value="Object.keys(locale)[0]"
>{{ Object.values(locale)[0] }}</option>
</select>
<span
class="mb-2 text-neutral-600 text-sm font-normal font-['Noto Sans JP']"
>{{ $t('submitPage.otherNotes')}}({{ $t('submitPage.optional')}})</span>
<input
class="mb-[71px] px-3 py-3.5 w-[350px] h-[50px] bg-white rounded-lg border border-zinc-400"
type="text"
v-model="submissionStore.otherNotes"
/>
<button
class="px-20 py-3 rounded-full bg-currentColor w-[350px] text-center text-white text-base font-medium font-['Noto Sans JP']"
@click="submissionStore.submit()"
>{{ $t('submitPage.submitButton')}}</button>
</div>
</template>

<script>
<script lang="ts" setup>
import { defineComponent, ref } from "vue";
import { useSubmissionStore } from "~/stores/submissionStore";
import { useLocaleStore } from "~/stores/localeStore";
const submissionStore = useSubmissionStore();
const localeStore = useLocaleStore();
</script>
25 changes: 4 additions & 21 deletions stores/localeStore.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
import { defineStore } from 'pinia'
import { defineStore } from "pinia";

const localeEn:{label: string, code: string} = {
label: 'English',
code: 'en'
}
const localeJa:{label: string, code: string} = {
label: '日本語',
code: 'ja'
}

export const useLocaleStore = defineStore('locale', {
export const useLocaleStore = defineStore('localeStore', {
state: () => ({
locale: localeEn
locales: [{"en_US": "English"}, {"ja_JP": "Japanese"}]
}),
getters: {
currentLocale: state => state.locale
},
getters: {},
actions: {
changeLocale() {
if (this.currentLocale.code === 'en')
this.locale = localeEn
else
this.locale = localeJa
}
}
})
24 changes: 24 additions & 0 deletions stores/submissionStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineStore } from "pinia";

export const useSubmissionStore = defineStore('submissionStore', {
state: () => ({
location: "",
lastName: "",
firstName: "",
selectLanguage1: "",
selectLanguage2: "",
otherNotes : ""
}),
getters: {},
actions: {
submit(): void {
const submission = {
"googleMapsUrl": this.location,
"healthcareProfessionalName": `${this.firstName} ${this.lastName}`,
"spokenLanguages": [this.selectLanguage1, this.selectLanguage2],
"notes": this.otherNotes
}
console.log('submission =', submission)
}
}
})

0 comments on commit 3ac3483

Please sign in to comment.