Files
alrahma_sunday_school_api/apps/api/src/modules/auth/auth.renter.service.ts
T
2026-06-11 03:22:12 -04:00

31 lines
1.2 KiB
TypeScript

import { AppError } from '../../http/errors'
import { presentRenterProfile } from './auth.presenter'
import * as repo from './auth.renter.repo'
import type { output } from 'zod'
import { renterUpdateSchema } from './auth.renter.schemas'
type RenterUpdateInput = output<typeof renterUpdateSchema>
export function signupDisabled() {
throw new AppError('Renter account creation is disabled. Only company owners can sign in to the platform.', 403, 'renter_signup_disabled')
}
export function loginDisabled() {
throw new AppError('Renter sign-in is disabled. Only company owners can sign in to the platform.', 403, 'renter_login_disabled')
}
export async function getMe(renterId: string) {
const renter = await repo.findRenterProfile(renterId)
const savedCompanies = await repo.findSavedCompanies(renter.savedCompanies.map((savedCompany: any) => savedCompany.companyId))
return presentRenterProfile(renter, savedCompanies)
}
export function updateMe(renterId: string, body: RenterUpdateInput) {
return repo.updateRenterProfile(renterId, body)
}
export async function updateFcmToken(renterId: string, fcmToken: string) {
await repo.updateRenterFcmToken(renterId, fcmToken)
return { success: true }
}