Skip to content

Commit

Permalink
Merge branch 'ermish/searchdata' of https://github.com/ourjapanlife/f…
Browse files Browse the repository at this point in the history
…indadoc-web into ermish/searchdata
  • Loading branch information
ermish committed Dec 6, 2023
2 parents 5ffb1ba + 76afc08 commit 1fa9506
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions stores/submissionStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { defineStore } from "pinia"
import { ref } from 'vue'
import { ref, watch } from 'vue'
import { useMutation } from '@vue/apollo-composable'
import gql from 'graphql-tag'
import { CreateSubmissionInput, Locale } from "~/typedefs/gqlTypes"

export const useSubmissionStore = defineStore('submissionStore', () => {
const location = ref('')
Expand All @@ -10,26 +13,47 @@ export const useSubmissionStore = defineStore('submissionStore', () => {
const otherNotes = ref('')
const submissionCompleted = ref(false)

const createSubmissionMutation = gql`mutation CreateSubmission($input: CreateSubmissionInput!) {
createSubmission(input: $input) {
id
googleMapsUrl
healthcareProfessionalName
spokenLanguages
isApproved
isRejected
isUnderReview
createdDate
updatedDate
}
}`




function submit() {
const spokenLanguages = []
const spokenLanguages: Locale[] = []

if (selectLanguage1.value !== '') {
console.log('selectLanguage1 =', selectLanguage1)
spokenLanguages.push(selectLanguage1.value)
spokenLanguages.push(selectLanguage1.value as Locale)
}

if (selectLanguage2.value !== '') {
spokenLanguages.push(selectLanguage2.value)
spokenLanguages.push(selectLanguage2.value as Locale)
}

const submission = {
"googleMapsUrl": location.value,
"healthcareProfessionalName": `${firstName.value} ${lastName.value}`,
"spokenLanguages": spokenLanguages,
"notes": otherNotes.value
}
} satisfies CreateSubmissionInput

console.log('submission =', submission)

const { mutate: sendSubmission } = useMutation(createSubmissionMutation, () => ({variables: {input: submission}}))

sendSubmission()
submissionCompleted.value = true
}

Expand Down

0 comments on commit 1fa9506

Please sign in to comment.