- Replaced `LIST_PUBLIC_CATEGORIES` with `LIST_ADMIN_CATEGORIES_FLAT` in `ArticleFormModal.tsx`. - Removed the "Add Event" button from the dashboard page. - Simplified the `EventsPage` by removing the button and adjusting the layout. - Cleaned up the `AdminEventEditPage` by removing unnecessary props. - Deleted unused layout and page files related to event creation. - Updated `AdminAuthContent` to use `useAdminCitiesQuery` instead of `useDiscoveryCitiesQuery`. - Refactored `EventGuestListAccessPanel` to remove the `accessMode` prop and adjust API calls accordingly. - Removed several unused components and tests related to event creation, enhancing project maintainability.
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import type { WalletTransactionResponseDto } from '@/api/generated/models'
|
|
import axiosInstance from '@/config/axios'
|
|
import { API_ROUTES } from '@/services/config'
|
|
import {
|
|
createServiceError,
|
|
errorResult,
|
|
handleServiceError,
|
|
type ServiceCallOptions,
|
|
type ServiceResult,
|
|
shouldBubbleErrorToParent,
|
|
successResult,
|
|
} from '@/services/errorHandler'
|
|
import { unwrapApiData, type ApiResponse } from '@/services/apiResponse'
|
|
|
|
export type WalletTransaction = WalletTransactionResponseDto
|
|
|
|
export interface AdminCreditWalletPayload {
|
|
/** Amount in Toman (integer). */
|
|
amount: number
|
|
description?: string
|
|
}
|
|
|
|
export interface AdminCreditWalletResult {
|
|
walletBalance: number
|
|
transaction: WalletTransaction
|
|
}
|
|
|
|
export const ADMIN_CREDIT_WALLET = async (
|
|
userId: string,
|
|
payload: AdminCreditWalletPayload,
|
|
options?: ServiceCallOptions
|
|
): Promise<ServiceResult<AdminCreditWalletResult>> => {
|
|
try {
|
|
const res = await axiosInstance.post<ApiResponse<AdminCreditWalletResult>>(API_ROUTES.USERS.ADMIN_WALLET_CREDIT(userId), payload)
|
|
const body = res.data
|
|
|
|
if (!body.success) {
|
|
throw createServiceError(body.message || 'شارژ کیفپول ناموفق بود')
|
|
}
|
|
|
|
const data = unwrapApiData(body)
|
|
|
|
if (data?.walletBalance === undefined || !data.transaction?.id) {
|
|
throw createServiceError('پاسخ نامعتبر از سرور')
|
|
}
|
|
|
|
return successResult(data)
|
|
} catch (error) {
|
|
const normalizedError = handleServiceError(error, options)
|
|
|
|
if (shouldBubbleErrorToParent(options)) {
|
|
throw normalizedError
|
|
}
|
|
|
|
return errorResult(normalizedError)
|
|
}
|
|
}
|