Files
hipmi-mobile/service/api-client/api-donation.ts
bagasbanuna b2be7be533 Saya telah melakukan serangkaian perubahan penting dalam pengembangan aplikasi HIPMI Mobile, khususnya dalam modul
Donasi. Berikut adalah ringkasan perubahan yang telah dilakukan:

     1. Menerapkan sistem pagination pada berbagai komponen layar donasi:
        - ScreenBeranda.tsx
        - ScreenMyDonation.tsx
        - ScreenRecapOfNews.tsx
        - ScreenListOfNews.tsx
        - ScreenListOfDonatur.tsx
        - ScreenFundDisbursement.tsx

     2. Memperbarui fungsi-fungsi API untuk mendukung parameter page:
        - apiDonationGetAll
        - apiDonationGetNewsById
        - apiDonationListOfDonaturById
        - apiDonationDisbursementOfFundsListById

     3. Mengganti komponen wrapper lama (ViewWrapper) dengan NewWrapper yang mendukung sistem pagination

     4. Membuat komponen layar terpisah untuk meningkatkan modularitas kode

     5. Memperbaiki berbagai error yang terjadi, termasuk masalah dengan import komponen dan struktur JSX

### No Issue
2026-02-10 17:30:30 +08:00

296 lines
5.5 KiB
TypeScript

import { apiConfig } from "../api-config";
export async function apiDonationCreate({
data,
category,
}: {
data: any;
category: "temporary" | "permanent";
}) {
try {
const response = await apiConfig.post(
`/mobile/donation?category=${category}`,
{
data: data,
}
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationGetOne({
id,
category,
}: {
id: string;
category: "temporary" | "permanent";
}) {
try {
const response = await apiConfig.get(
`/mobile/donation/${id}?category=${category}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationGetByStatus({
authorId,
status,
page = "1",
}: {
authorId: string;
status: string;
page?: string;
}) {
const authorQuery = `/${authorId}`;
const statusQuery = `/${status}`;
const pageQuery = `?page=${page}`;
try {
const response = await apiConfig.get(
`/mobile/donation${authorQuery}${statusQuery}${pageQuery}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationUpdateStatus({
id,
status,
}: {
id: string;
status: "draft" | "review" | "publish" | "reject";
}) {
try {
const response = await apiConfig.put(`/mobile/donation/${id}/${status}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationDelete({ id }: { id: string }) {
try {
const response = await apiConfig.delete(`/mobile/donation/${id}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationUpdateData({
id,
data,
category,
}: {
id: string;
data: any;
category: "edit-donation" | "edit-story" | "edit-bank-account";
}) {
try {
const response = await apiConfig.put(
`/mobile/donation/${id}?category=${category}`,
{
data: data,
}
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationGetAll({
category,
authorId,
page = "1"
}: {
category: "beranda" | "my-donation";
authorId?: string;
page?: string;
}) {
const authorQuery = authorId ? `&authorId=${authorId}` : "";
const pageQuery = `&page=${page}`;
try {
const response = await apiConfig.get(
`/mobile/donation?category=${category}${authorQuery}${pageQuery}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationFundrising({ id }: { id: string }) {
try {
const response = await apiConfig.get(`/mobile/donation/${id}/fundrising`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationCreateDonatur({
id,
data,
}: {
id: string;
data: any;
}) {
try {
const response = await apiConfig.post(`/mobile/donation/${id}/donatur`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationCreateInvoice({
id,
data,
}: {
id: string;
data: any;
}) {
try {
const response = await apiConfig.post(`/mobile/donation/${id}/invoice`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationGetInvoiceById({ id }: { id: string }) {
try {
const response = await apiConfig.get(`/mobile/donation/${id}/invoice`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationUpdateInvoice({
id,
fileId,
status,
}: {
id: string;
fileId?: string;
status: "berhasil" | "gagal" | "proses" | "menunggu";
}) {
const statusQuery = `?status=${status}`;
try {
const response = await apiConfig.put(
`/mobile/donation/${id}/invoice${statusQuery}`,
{
data: fileId,
}
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationCreateNews({
id,
data,
}: {
id: string;
data: any;
}) {
try {
const response = await apiConfig.post(`/mobile/donation/${id}/news`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationGetNewsById({
id,
category,
page = "1"
}: {
id: string;
category: "get-all" | "get-one";
page?: string;
}) {
try {
const response = await apiConfig.get(
`/mobile/donation/${id}/news?category=${category}&page=${page}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationUpdateNews({
id,
data,
}: {
id: string;
data: any;
}) {
try {
const response = await apiConfig.put(`/mobile/donation/${id}/news`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationDeleteNews({ id }: { id: string }) {
try {
const response = await apiConfig.delete(`/mobile/donation/${id}/news`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationDisbursementOfFundsListById({
id,
page = "1"
}: {
id: string;
page?: string;
}) {
try {
const response = await apiConfig.get(`/mobile/donation/${id}/disbursement?page=${page}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationListOfDonaturById({
id,
page = "1"
}: {
id: string;
page?: string;
}) {
try {
const response = await apiConfig.get(`/mobile/donation/${id}/donatur?page=${page}`);
return response.data;
} catch (error) {
throw error;
}
}