Changed resuce to status to allow cancellation, enabled email notifications
This commit is contained in:
@@ -314,7 +314,18 @@ export const listRescueWorkspacesForAdmin = async () => {
|
||||
export const updateRescueVerificationStatus = async (workspaceId: number, status: RescueVerificationStatus) => {
|
||||
const result = await db.query<WorkspaceRow>(
|
||||
`UPDATE workspaces
|
||||
SET rescue_verification_status = $2,
|
||||
SET workspace_type = CASE
|
||||
WHEN $2 = 'rejected' THEN 'standard'
|
||||
ELSE workspace_type
|
||||
END,
|
||||
billing_plan = CASE
|
||||
WHEN $2 = 'rejected' THEN 'household_basic'
|
||||
ELSE billing_plan
|
||||
END,
|
||||
rescue_verification_status = CASE
|
||||
WHEN $2 = 'rejected' THEN 'not_required'
|
||||
ELSE $2
|
||||
END,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $1
|
||||
AND workspace_type = 'rescue'
|
||||
@@ -325,6 +336,23 @@ export const updateRescueVerificationStatus = async (workspaceId: number, status
|
||||
return result.rows[0] ?? null;
|
||||
};
|
||||
|
||||
export const cancelRescueVerificationRequest = async (workspaceId: number) => {
|
||||
const result = await db.query<WorkspaceRow>(
|
||||
`UPDATE workspaces
|
||||
SET workspace_type = 'standard',
|
||||
billing_plan = 'household_basic',
|
||||
rescue_verification_status = 'not_required',
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $1
|
||||
AND workspace_type = 'rescue'
|
||||
AND rescue_verification_status = 'pending'
|
||||
RETURNING id, name, workspace_type, billing_email, billing_plan, subscription_status, rescue_verification_status, created_at, updated_at`,
|
||||
[workspaceId],
|
||||
);
|
||||
|
||||
return result.rows[0] ?? null;
|
||||
};
|
||||
|
||||
export const getPlatformAdminSummary = async () => {
|
||||
const result = await db.query<{
|
||||
total_birds: number;
|
||||
|
||||
Reference in New Issue
Block a user