23 lines
689 B
TypeScript
23 lines
689 B
TypeScript
|
|
import { ExpressController } from "@erp/core/api";
|
||
|
|
|
||
|
|
import type { GetInitialOnboardingStatusUseCase } from "../../application";
|
||
|
|
|
||
|
|
export class GetInitialOnboardingStatusController extends ExpressController {
|
||
|
|
constructor(private readonly useCase: GetInitialOnboardingStatusUseCase) {
|
||
|
|
super();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected async executeImpl() {
|
||
|
|
const user = this.getUser();
|
||
|
|
if (!user?.userId) {
|
||
|
|
return this.unauthorizedError("Unauthorized");
|
||
|
|
}
|
||
|
|
|
||
|
|
const result = await this.useCase.execute({ accountId: user.userId });
|
||
|
|
return result.match(
|
||
|
|
(value) => this.ok({ status: value.status, company_id: value.companyId }),
|
||
|
|
(error) => this.handleError(error)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|