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

254 - Endpoint Configuration for vet_verification_status #10480

Merged
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions VAMobile/src/api/types/VeteranVerificationStatusPayload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type VeteranStatus = 'confirmed' | 'not confirmed'

export type VeteranVerificationStatusDataAttributes = {
veteranStatus: VeteranStatus
notConfirmedReason?: string
}

export type VeteranVerificationStatusPayload = {
data: {
id: string
type: string
attributes: VeteranVerificationStatusDataAttributes
message?: string[]
}
}
1 change: 1 addition & 0 deletions VAMobile/src/api/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './PrescriptionData'
export * from './SecureMessagingData'
export * from './ServiceHistoryData'
export * from './VaccineData'
export * from './VeteranVerificationStatusPayload'
32 changes: 32 additions & 0 deletions VAMobile/src/api/veteranStatus/getVeteranStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useQuery } from '@tanstack/react-query'

import { VeteranVerificationStatusPayload } from 'api/types'
import { ACTIVITY_STALE_TIME } from 'constants/common'
import { get } from 'store/api'

import { veteranStatusKeys } from './queryKeys'

/**
* Fetch veteran verification status
*/
const getVeteranStatus = async (): Promise<VeteranVerificationStatusPayload | undefined> => {
const response = await get<VeteranVerificationStatusPayload>('/v0/vet_verification_status')
if (response) {
return response
}
}

/**
* Returns a query for a veterans verification status
*/
export const useVeteranStatus = (options?: { enabled?: boolean }) => {
return useQuery({
...options,
queryKey: veteranStatusKeys.verification,
queryFn: () => getVeteranStatus(),
meta: {
errorName: 'getVeteranStatus: Service error',
},
staleTime: ACTIVITY_STALE_TIME,
})
}
2 changes: 2 additions & 0 deletions VAMobile/src/api/veteranStatus/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './getVeteranStatus'
export * from './queryKeys'
3 changes: 3 additions & 0 deletions VAMobile/src/api/veteranStatus/queryKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const veteranStatusKeys = {
verification: ['verification'] as const,
}
Loading