58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import type {
|
|
ActivateOldItemRewardConfigRequest,
|
|
AdjustOldItemPointsRequest,
|
|
OldItemCertificateItem,
|
|
OldItemPointAccountItem,
|
|
OldItemPointEntryItem,
|
|
OldItemRewardConfig,
|
|
} from '@lehuo/contracts';
|
|
import { apiRequest } from './api-client';
|
|
import type { Page } from './old-items';
|
|
|
|
export const getOldItemRewardConfig = () =>
|
|
apiRequest<{ config: OldItemRewardConfig; usesDefault: boolean }>(
|
|
'/api/v1/admin/old-items/reward-config',
|
|
);
|
|
export const activateOldItemRewardConfig = (
|
|
input: Omit<ActivateOldItemRewardConfigRequest, 'clientRequestId'>,
|
|
) =>
|
|
apiRequest<{ config: OldItemRewardConfig }>('/api/v1/admin/old-items/reward-config/activate', {
|
|
method: 'POST',
|
|
body: JSON.stringify({ ...input, clientRequestId: crypto.randomUUID() }),
|
|
});
|
|
export const listOldItemPointAccounts = () =>
|
|
apiRequest<Page<OldItemPointAccountItem>>(
|
|
'/api/v1/admin/old-items/reward-accounts?page=1&pageSize=100',
|
|
);
|
|
export const adjustOldItemPoints = (
|
|
userPublicId: string,
|
|
input: Omit<AdjustOldItemPointsRequest, 'clientRequestId'>,
|
|
) =>
|
|
apiRequest<{ entry: OldItemPointEntryItem }>(
|
|
`/api/v1/admin/old-items/reward-accounts/${userPublicId}/adjust`,
|
|
{
|
|
method: 'POST',
|
|
body: JSON.stringify({ ...input, clientRequestId: crypto.randomUUID() }),
|
|
},
|
|
);
|
|
export const listOldItemCertificates = () =>
|
|
apiRequest<Page<OldItemCertificateItem>>(
|
|
'/api/v1/admin/old-items/certificates?page=1&pageSize=100',
|
|
);
|
|
export const issueOldItemCertificate = (donationPublicId: string) =>
|
|
apiRequest<{ certificate: OldItemCertificateItem }>(
|
|
`/api/v1/admin/old-items/donations/${donationPublicId}/certificate`,
|
|
{
|
|
method: 'POST',
|
|
body: JSON.stringify({ clientRequestId: crypto.randomUUID() }),
|
|
},
|
|
);
|
|
export const revokeOldItemCertificate = (publicId: string, reason: string) =>
|
|
apiRequest<{ certificate: OldItemCertificateItem }>(
|
|
`/api/v1/admin/old-items/certificates/${publicId}/revoke`,
|
|
{
|
|
method: 'POST',
|
|
body: JSON.stringify({ clientRequestId: crypto.randomUUID(), reason }),
|
|
},
|
|
);
|