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

chore: add request to submit to db #302

Closed
wants to merge 1 commit into from
Closed
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
41 changes: 39 additions & 2 deletions stores/submissionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@ export const useSubmissionStore = defineStore('submissionStore', () => {
const selectLanguage2 = ref('')
const otherNotes = ref('')

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


async function submit() {
const spokenLanguages = []

if (selectLanguage1.value !== 'none') {
Expand All @@ -26,7 +41,29 @@ export const useSubmissionStore = defineStore('submissionStore', () => {
"spokenLanguages": spokenLanguages,
"notes": otherNotes.value
}
console.log('submission =', submission)

const createSubmissionRequest = {
query: createSubmissionMutation,
variables: {
input: submission
}
}

// Write a request using createSubmissionRequest to the GraphQL API https://findadoc-api-9brq4.ondigitalocean.app/api

const response = await fetch('https://findadoc-api-9brq4.ondigitalocean.app/api', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify(createSubmissionRequest)
})
//



console.log('response =', response)
}

return { location, firstName, lastName, selectLanguage1, selectLanguage2, otherNotes, submit }
Expand Down
Loading