fix docs
This commit is contained in:
@@ -6,6 +6,7 @@ import type {
|
||||
CreateWalletsResponse,
|
||||
WalletResponse,
|
||||
DocumentResponse,
|
||||
DocumentTypeSlug,
|
||||
Organization,
|
||||
OrganizationListResponse,
|
||||
PurchaseRequestListResponse,
|
||||
@@ -138,18 +139,19 @@ export function getDocuments(orgId: string): Promise<DocumentResponse[]> {
|
||||
)
|
||||
}
|
||||
|
||||
// Upload/replace a single typed document. The type is part of the path and
|
||||
// the body carries only the file — PUT acts as an upsert for that slot.
|
||||
export function uploadDocument(
|
||||
orgId: string,
|
||||
documentType: string,
|
||||
type: DocumentTypeSlug,
|
||||
file: File,
|
||||
): Promise<DocumentResponse> {
|
||||
const body = new FormData()
|
||||
body.append('document_type', documentType)
|
||||
body.append('file', file)
|
||||
|
||||
return doAdminRequest<DocumentResponse>(
|
||||
`/v1/organizations/${orgId}/documents`,
|
||||
{ method: 'POST', body },
|
||||
`/v1/organizations/${orgId}/documents/${type}`,
|
||||
{ method: 'PUT', body },
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { uploadDocument } from '../api/adminApi'
|
||||
import type { DocumentTypeSlug } from '../model/types'
|
||||
import { DOCUMENTS_QUERY_KEY } from './useDocuments'
|
||||
|
||||
interface UploadArgs {
|
||||
documentType: string
|
||||
type: DocumentTypeSlug
|
||||
file: File
|
||||
}
|
||||
|
||||
export function useUploadDocument(orgId: string) {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: ({ documentType, file }: UploadArgs) =>
|
||||
uploadDocument(orgId, documentType, file),
|
||||
mutationFn: ({ type, file }: UploadArgs) =>
|
||||
uploadDocument(orgId, type, file),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: DOCUMENTS_QUERY_KEY(orgId) })
|
||||
},
|
||||
|
||||
@@ -24,6 +24,7 @@ export type {
|
||||
UpdateOrganizationRequest,
|
||||
WalletResponse,
|
||||
DocumentResponse,
|
||||
DocumentTypeSlug,
|
||||
PurchaseRequestResponse,
|
||||
PurchaseRequestListResponse,
|
||||
BankDetails,
|
||||
|
||||
@@ -67,15 +67,25 @@ export interface CreateWalletsResponse {
|
||||
mnemonic: string
|
||||
}
|
||||
|
||||
// Fixed document type slugs — match the path segments of the per-type
|
||||
// PUT/GET endpoints (`/documents/{slug}`). The API no longer accepts a
|
||||
// free-text document type.
|
||||
export type DocumentTypeSlug =
|
||||
| 'charter'
|
||||
| 'inn-certificate'
|
||||
| 'ogrn-certificate'
|
||||
| 'bank-details'
|
||||
| 'kyc-representative'
|
||||
| 'power-of-attorney'
|
||||
| 'other'
|
||||
|
||||
export interface DocumentResponse {
|
||||
id: string
|
||||
organization_id: string
|
||||
document_type: string
|
||||
file_name: string
|
||||
content_type: string
|
||||
file_size_bytes: number
|
||||
uploaded_by: string | null
|
||||
created_at: string | null
|
||||
s3_key: string | null
|
||||
file_name: string | null
|
||||
content_type: string | null
|
||||
file_size_bytes: number | null
|
||||
download_url: string | null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user