- Implemented MpReauthNotice component to notify users when reauthorization is needed. - Created MpStatusCard component to display the current status of the Mercado Pago account. - Added utility functions and constants for handling Mercado Pago status and messages. - Introduced hooks for managing the connection and disconnection of Mercado Pago accounts. - Developed a disconnect confirmation modal for user actions. - Added tests for the new functionality and utility functions. - Defined schemas for Mercado Pago account status and callback reasons in shared package.
22 lines
774 B
TypeScript
22 lines
774 B
TypeScript
import type { MpConnectQuery, MpReturnTo } from '@gruperly/shared';
|
|
import { MpConnectQuerySchema } from '@gruperly/shared';
|
|
import { Hono } from 'hono';
|
|
import { problemJson, resultJson, unauthorizedProblem } from '@/http/problem-details';
|
|
import { validate } from '@/http/validate';
|
|
import { StartMpAuthorization } from './use-case';
|
|
|
|
const route = new Hono();
|
|
|
|
route.get('/', validate.query(MpConnectQuerySchema), async (c) => {
|
|
const user = c.get('user');
|
|
if (!user) return problemJson(c, unauthorizedProblem(c.req.path));
|
|
|
|
const { returnTo } = c.req.valid('query') as MpConnectQuery;
|
|
|
|
const useCase = new StartMpAuthorization();
|
|
const result = await useCase.execute(user.id, returnTo as MpReturnTo);
|
|
return resultJson(c, result);
|
|
});
|
|
|
|
export default route;
|