feat: standardize correspondent and tag types with usage count
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { MutableRefObject, useCallback, useState } from 'react';
|
||||
import type { Correspondent } from '../../types/documents';
|
||||
|
||||
type ApiClient = {
|
||||
get: (path: string) => Promise<{ data: unknown }>;
|
||||
@@ -7,12 +8,6 @@ type ApiClient = {
|
||||
delete: (path: string) => Promise<{ data: unknown }>;
|
||||
};
|
||||
|
||||
interface CorrespondentEntry {
|
||||
id?: string;
|
||||
name?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
interface UseCorrespondentsOptions {
|
||||
apiClient: ApiClient;
|
||||
notifyApiError: (error: unknown, fallback: string) => void;
|
||||
@@ -28,7 +23,7 @@ const useCorrespondents = ({
|
||||
tenantIdRef,
|
||||
mapDocumentCaches,
|
||||
}: UseCorrespondentsOptions) => {
|
||||
const [correspondents, setCorrespondents] = useState<CorrespondentEntry[]>([]);
|
||||
const [correspondents, setCorrespondents] = useState<Correspondent[]>([]);
|
||||
|
||||
const refreshCorrespondents = useCallback(async () => {
|
||||
const requestTenantId = tenantIdRef.current;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MutableRefObject, useCallback, useState } from 'react';
|
||||
import type { TagId, TenantId } from '../../types/identifiers';
|
||||
import type { Tag } from '../../types/documents';
|
||||
|
||||
type ApiClient = {
|
||||
get: (path: string) => Promise<{ data: unknown }>
|
||||
@@ -12,13 +13,6 @@ interface TagManagerInterface {
|
||||
buildPayload: (input: { label?: string; color?: string | null }) => { label: string; color: string | null };
|
||||
}
|
||||
|
||||
interface TagEntry {
|
||||
id?: TagId;
|
||||
label?: string;
|
||||
color?: string | null;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
interface UseTagsOptions {
|
||||
apiClient: ApiClient;
|
||||
notifyApiError: (error: unknown, fallback: string) => void;
|
||||
@@ -38,7 +32,7 @@ const useTags = ({
|
||||
setActiveTagFilters,
|
||||
mapDocumentCaches,
|
||||
}: UseTagsOptions) => {
|
||||
const [tags, setTags] = useState<TagEntry[]>([]);
|
||||
const [tags, setTags] = useState<Tag[]>([]);
|
||||
|
||||
const refreshTags = useCallback(async () => {
|
||||
const requestTenantId = tenantIdRef.current;
|
||||
|
||||
Reference in New Issue
Block a user