- 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.
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import type { CompleteProfileDto, UserProfileResponseDto } from '@/api/generated/models'
|
|
import {
|
|
createServiceError,
|
|
errorResult,
|
|
handleServiceError,
|
|
type ServiceCallOptions,
|
|
type ServiceResult,
|
|
shouldBubbleErrorToParent,
|
|
successResult,
|
|
} from '@/services/errorHandler'
|
|
import { unwrapApiData } from '@/services/apiResponse'
|
|
import { ANALYTICS_EVENTS, trackAnalyticsEventOnce } from '@/lib/analytics'
|
|
import { getUsers } from '@/api/generated/users/users'
|
|
import { texts } from '@/texts'
|
|
|
|
export type UserProfile = UserProfileResponseDto
|
|
export type CompleteProfilePayload = CompleteProfileDto
|
|
|
|
const usersApi = getUsers()
|
|
|
|
/** Completes first-time admin profile after OTP registration. */
|
|
export const COMPLETE_PROFILE = async (data: CompleteProfilePayload, options?: ServiceCallOptions): Promise<ServiceResult<UserProfile>> => {
|
|
try {
|
|
const res = await usersApi.usersControllerCompleteProfile({
|
|
firstName: data.firstName.trim(),
|
|
lastName: data.lastName.trim(),
|
|
gender: data.gender,
|
|
dateOfBirth: data.dateOfBirth,
|
|
cityId: data.cityId,
|
|
})
|
|
const payload = res.data
|
|
|
|
if (!payload.success) {
|
|
throw createServiceError(payload.message || texts.profile.completeProfileFailed)
|
|
}
|
|
|
|
const profile = unwrapApiData(payload)
|
|
|
|
if (!profile?.id) {
|
|
throw createServiceError(texts.common.invalidServerResponse)
|
|
}
|
|
|
|
trackAnalyticsEventOnce(ANALYTICS_EVENTS.SIGN_UP, profile.id, { method: 'otp_profile_completion' })
|
|
|
|
return successResult(profile)
|
|
} catch (error) {
|
|
const normalizedError = handleServiceError(error, options)
|
|
|
|
if (shouldBubbleErrorToParent(options)) {
|
|
throw normalizedError
|
|
}
|
|
|
|
return errorResult(normalizedError)
|
|
}
|
|
}
|