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

feat: add mutation to delete healthcare professional #846

Merged
merged 3 commits into from
Nov 5, 2024
Merged
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
28 changes: 26 additions & 2 deletions stores/healthcareProfessionalsStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { defineStore } from 'pinia'
import { ref, type Ref } from 'vue'
import { gql } from 'graphql-request'
import type { HealthcareProfessional, MutationUpdateHealthcareProfessionalArgs } from '~/typedefs/gqlTypes'
import type { HealthcareProfessional,
MutationDeleteHealthcareProfessionalArgs,
MutationUpdateHealthcareProfessionalArgs } from '~/typedefs/gqlTypes'
import { gqlClient, graphQLClientRequestWithRetry } from '~/utils/graphql'

export const useHealthcareProfessionalsStore = defineStore(
Expand All @@ -28,11 +30,24 @@ export const useHealthcareProfessionalsStore = defineStore(
}
}

async function deleteHealthcareProfessional(healthcareProfessionalId: MutationDeleteHealthcareProfessionalArgs) {
try {
return await graphQLClientRequestWithRetry(
gqlClient.request.bind(gqlClient),
deleteHealthcareProfessionalGqlMutation,
healthcareProfessionalId
)
} catch (error) {
console.error('Failed to delete healthcare professional:', error)
}
}

return {
getHealthcareProfessionals,
healthcareProfessionalsData,
updateHealthcareProfessional,
selectedHealthcareProfessionalId
selectedHealthcareProfessionalId,
deleteHealthcareProfessional
}
}
)
Expand Down Expand Up @@ -126,3 +141,12 @@ mutation Mutation($updateHealthcareProfessionalId: ID!, $input: UpdateHealthcare
}
}
`

const deleteHealthcareProfessionalGqlMutation = gql`
mutation Mutation($deleteHealthcareProfessionalId: ID!) {
deleteHealthcareProfessional(id: $deleteHealthcareProfessionalId) {
isSuccessful
NabbeunNabi marked this conversation as resolved.
Show resolved Hide resolved
}
}
`

Loading