diff --git a/src/app/api/relationships/updateRequest/route.ts b/src/app/api/relationships/updateStatus/route.ts similarity index 86% rename from src/app/api/relationships/updateRequest/route.ts rename to src/app/api/relationships/updateStatus/route.ts index e255393..ce94a00 100644 --- a/src/app/api/relationships/updateRequest/route.ts +++ b/src/app/api/relationships/updateStatus/route.ts @@ -1,10 +1,10 @@ "use server"; import { NextResponse } from "next/server"; import type { NextRequest } from "next/server"; -import { updateRelationshipRequest } from "~/server/functions"; +import { updateRelationshipStatus } from "~/server/functions"; import { middleware } from "~/middleware"; -interface UpdateRequestRequest { +interface UpdateStatusRequest { relationshipId: number; status: 'accepted' | 'rejected'; } @@ -13,14 +13,14 @@ export async function POST(request: NextRequest) { const middlewareResponse = await middleware(request); if (middlewareResponse) return middlewareResponse; try { - const { relationshipId, status } = await request.json() as UpdateRequestRequest; + const { relationshipId, status } = await request.json() as UpdateStatusRequest; console.log("Received request:", { relationshipId, status }); if (!relationshipId || !status || isNaN(relationshipId)) return NextResponse.json({ message: "Missing required fields" }, { status: 400 }); console.log("Updating relationship request:", relationshipId); - const result = await updateRelationshipRequest(relationshipId, status); + const result = await updateRelationshipStatus(relationshipId, status); if (result.success) { console.log("Relationship request updated successfully"); diff --git a/src/app/relationships/updateRequest/page.tsx b/src/app/relationships/updateStatus/page.tsx similarity index 92% rename from src/app/relationships/updateRequest/page.tsx rename to src/app/relationships/updateStatus/page.tsx index f171dfa..2f12e4b 100644 --- a/src/app/relationships/updateRequest/page.tsx +++ b/src/app/relationships/updateStatus/page.tsx @@ -4,7 +4,7 @@ import React, { useState } from 'react'; type status = 'pending' | 'accepted' | 'rejected'; -export default function UpdateRequestPage() { +export default function UpdateStatusPage() { const [relationshipId, setRelationshipId] = useState(""); const [status, setStatus] = useState(""); const [result, setResult] = useState(null); @@ -14,7 +14,7 @@ export default function UpdateRequestPage() { setResult(null); try { - const response = await fetch('/api/relationships/updateRequest', { + const response = await fetch('/api/relationships/updateStatus', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -37,7 +37,7 @@ export default function UpdateRequestPage() {
-

Test Send Message

+

Update Relationship Status

diff --git a/src/server/functions.ts b/src/server/functions.ts index 9165bf9..8be0045 100755 --- a/src/server/functions.ts +++ b/src/server/functions.ts @@ -407,7 +407,7 @@ export const createRelationshipRequest = async (requestorId: number, requestedId } }; -export const updateRelationshipRequest = async (relationshipId: number, status: 'accepted' | 'rejected') => { +export const updateRelationshipStatus = async (relationshipId: number, status: 'accepted' | 'rejected') => { try { const relationship = await db.select().from(schema.relationships) .where(eq(schema.relationships.id, relationshipId));