46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import api from './client';
|
|
|
|
export type BarcodeActionType = 'SEND_TO_PAPERLESS' | 'SEND_BY_EMAIL';
|
|
|
|
export interface BarcodeTemplate {
|
|
Id: number;
|
|
Name: string;
|
|
Regex: string;
|
|
SplitBefore: boolean;
|
|
DateinameTemplate: string | null;
|
|
Actions: BarcodeActionType[];
|
|
CreatedAt: string;
|
|
UpdatedAt: string;
|
|
}
|
|
|
|
export interface BarcodeTemplateInput {
|
|
Name: string;
|
|
Regex: string;
|
|
SplitBefore: boolean;
|
|
DateinameTemplate?: string | null;
|
|
Actions: BarcodeActionType[];
|
|
}
|
|
|
|
export const BARCODE_ACTION_LABELS: Record<BarcodeActionType, string> = {
|
|
SEND_TO_PAPERLESS: 'Datei an Paperless senden',
|
|
SEND_BY_EMAIL: 'Datei per E-Mail senden',
|
|
};
|
|
|
|
export const barcodeTemplatesApi = {
|
|
list: () =>
|
|
api.get<BarcodeTemplate[]>('/api/barcode-templates').then((r) => r.data),
|
|
|
|
create: (input: BarcodeTemplateInput) =>
|
|
api
|
|
.post<BarcodeTemplate>('/api/barcode-templates', input)
|
|
.then((r) => r.data),
|
|
|
|
update: (id: number, input: Partial<BarcodeTemplateInput>) =>
|
|
api
|
|
.put<BarcodeTemplate>(`/api/barcode-templates/${id}`, input)
|
|
.then((r) => r.data),
|
|
|
|
remove: (id: number) =>
|
|
api.delete(`/api/barcode-templates/${id}`).then((r) => r.data),
|
|
};
|