bugfix: copy/regenerate link for invitation action added to connection request lis in orgs feature.
This commit is contained in:
@@ -13,12 +13,18 @@ import {
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { AcceptOrganizationInviteDto } from './dto/accept-organization-invite.dto';
|
||||
import { CreateLinkRequestDto } from './dto/create-link-request.dto';
|
||||
import { CreateConnectionRequestDto } from './dto/create-connection-request.dto';
|
||||
import { InviteOrganizationDto } from './dto/invite-organization.dto';
|
||||
import { PreviewOrganizationInviteDto } from './dto/preview-organization-invite.dto';
|
||||
import { RespondLinkRequestDto } from './dto/respond-link-request.dto';
|
||||
import { RespondConnectionRequestDto } from './dto/respond-connection-request.dto';
|
||||
import { OrganizationService } from './organization.service';
|
||||
|
||||
/**
|
||||
* Counterpart orgs (clinic↔lab).
|
||||
*
|
||||
* - `/connections` — OrganizationLink rows (connection requests + links created by invites).
|
||||
* - `/invite`, `/invitations/*` — signup invitation tokens (orgs not yet on DyoLink).
|
||||
*/
|
||||
@ApiTags('organizations')
|
||||
@ApiBearerAuth('JWT-auth')
|
||||
@Controller('organizations')
|
||||
@@ -58,46 +64,53 @@ export class OrganizationController {
|
||||
return this.organizationService.searchCounterpartOrganizations(req.user.id, organizationId, q);
|
||||
}
|
||||
|
||||
@Get('links')
|
||||
@Get('connections')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiOperation({ summary: 'List counterpart links and invitations for current org' })
|
||||
list(@Req() req: { user: { id: string; organizationId?: string } }) {
|
||||
@ApiOperation({ summary: 'List counterpart connections for current organization' })
|
||||
listConnections(@Req() req: { user: { id: string; organizationId?: string } }) {
|
||||
const organizationId = this.organizationService.getOrganizationIdFromUser(req.user);
|
||||
return this.organizationService.list(req.user.id, organizationId);
|
||||
}
|
||||
|
||||
@Post('links')
|
||||
@Post('connections')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiOperation({ summary: 'Create pending link request to an existing subscribed counterpart org' })
|
||||
createLinkRequest(
|
||||
@ApiOperation({
|
||||
summary: 'Create pending connection request to an existing subscribed counterpart org',
|
||||
})
|
||||
createConnectionRequest(
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
@Body() dto: CreateLinkRequestDto,
|
||||
@Body() dto: CreateConnectionRequestDto,
|
||||
) {
|
||||
const organizationId = this.organizationService.getOrganizationIdFromUser(req.user);
|
||||
return this.organizationService.createLinkRequest(req.user.id, organizationId, dto);
|
||||
return this.organizationService.createConnectionRequest(req.user.id, organizationId, dto);
|
||||
}
|
||||
|
||||
@Patch('links/:linkId/respond')
|
||||
@Patch('connections/:connectionId/respond')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiOperation({ summary: 'Accept or reject a pending link request for current organization' })
|
||||
respondToLinkRequest(
|
||||
@ApiOperation({ summary: 'Accept or reject a pending connection request for current organization' })
|
||||
respondToConnectionRequest(
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
@Param('linkId') linkId: string,
|
||||
@Body() dto: RespondLinkRequestDto,
|
||||
@Param('connectionId') connectionId: string,
|
||||
@Body() dto: RespondConnectionRequestDto,
|
||||
) {
|
||||
const organizationId = this.organizationService.getOrganizationIdFromUser(req.user);
|
||||
return this.organizationService.respondToLinkRequest(req.user.id, organizationId, linkId, dto);
|
||||
return this.organizationService.respondToConnectionRequest(
|
||||
req.user.id,
|
||||
organizationId,
|
||||
connectionId,
|
||||
dto,
|
||||
);
|
||||
}
|
||||
|
||||
@Delete('links/:linkId')
|
||||
@Delete('connections/:connectionId')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiOperation({ summary: 'Delete linked organization record' })
|
||||
deleteLink(
|
||||
@ApiOperation({ summary: 'Remove an active connection' })
|
||||
deleteConnection(
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
@Param('linkId') linkId: string,
|
||||
@Param('connectionId') connectionId: string,
|
||||
) {
|
||||
const organizationId = this.organizationService.getOrganizationIdFromUser(req.user);
|
||||
return this.organizationService.deleteLink(req.user.id, organizationId, linkId);
|
||||
return this.organizationService.deleteConnection(req.user.id, organizationId, connectionId);
|
||||
}
|
||||
|
||||
@Post('invitations/:invitationId/link')
|
||||
|
||||
Reference in New Issue
Block a user