Skip to content

Commit

Permalink
fix: path
Browse files Browse the repository at this point in the history
  • Loading branch information
alarv committed Sep 27, 2024
1 parent 00d766d commit 91839f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions app/api/leads/route.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
import { auth } from "@/auth";
import { NextResponse } from "next/server";
import { isAuthenticated } from "@/lib/utils";
import { ApiResponse, errorResponse, handleApiResponse } from "@/lib/response";
import { auth } from '@/auth';
import { NextResponse } from 'next/server';
import { isAuthenticated } from '@/lib/utils';
import {
ApiResponse,
errorResponse,
handleApiResponse,
} from '@/app/util/response';

export async function POST(
request: Request,
): Promise<NextResponse<ApiResponse>> {
const session = await auth();
if (!isAuthenticated(session)) {
return errorResponse(
"You need to be authenticated to access this endpoint",
'You need to be authenticated to access this endpoint',
401,
);
}

const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/v1/leads`, {
method: "POST",
method: 'POST',
headers: {
Authorization: `Bearer ${session!.token}`,
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});

const apiResponse = await handleApiResponse(res);
const data = await apiResponse.json();

if (data.success) {
const leadUrl = res.headers.get("Location")!;
const leadUrlParts = leadUrl.split("/");
const leadUrl = res.headers.get('Location')!;
const leadUrlParts = leadUrl.split('/');
const leadId = leadUrlParts[leadUrlParts.length - 1];

return NextResponse.json(
Expand Down
2 changes: 1 addition & 1 deletion app/pricing/components/Pricing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button } from '@nextui-org/button';
import { signIn, useSession } from 'next-auth/react';
import { isAuthenticated } from '@/lib/utils';
import toast from 'react-hot-toast';
import { ApiResponse } from '@/lib/response';
import { ApiResponse } from '@/app/util/response';
import { useCallback, useState } from 'react';

export default function Pricing() {
Expand Down

0 comments on commit 91839f0

Please sign in to comment.