Skip to content

Commit

Permalink
feat: add mutation to delete healthcare professional (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
NabbeunNabi authored Nov 5, 2024
1 parent b06deeb commit fcd0117
Showing 1 changed file with 26 additions and 2 deletions.
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
}
}
`

0 comments on commit fcd0117

Please sign in to comment.