Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szewczyk committed Feb 21, 2025
1 parent 52b1a97 commit d73831b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/frontend/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ export const handleMutationError = (error: any, action: string): never => {
throw new Error(`Failed to ${action}: ${errorMessage}`);
};

export const postRequest = async (
export const postRequest = async <T>(
url: string,
body: any,
errorMessage: string,
) => {
): Promise<T> => {
try {
const response = await api.post(url, body);
return response.data as T;
Expand Down
18 changes: 10 additions & 8 deletions src/frontend/src/api/programsApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { api, handleApiResponse } from './api';
import { Program } from '@restgenerated/models/Program';
// import { ProgramCreate } from '@restgenerated/models/ProgramCreate';

//TODO: Add generated types
Expand All @@ -13,19 +12,22 @@ interface BeneficiaryGroup {
master_detail: boolean;
}

export interface PaginatedListResponse<T> {
count: number;
next?: string;
previous?: string;
results: T[];
}

export const fetchBeneficiaryGroups = async (): Promise<
PaginatedListResponse<BeneficiaryGroup>
> => {
return handleApiResponse(api.get('beneficiary-groups/'));
};

interface Program {
id: string;
name: string;
description: string;
status: string;
business_area: string;
created_at: string;
updated_at: string;
}

export const fetchProgram = async (
businessArea: string,
programId: string,
Expand Down

0 comments on commit d73831b

Please sign in to comment.