From 07819844d5ef7e323fd956eacfedecb2f4f4bb80 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 17 Nov 2023 15:16:23 +0700
Subject: Update result feature

---
 src/app/api/location/route.tsx | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

(limited to 'src/app/api/location/route.tsx')

diff --git a/src/app/api/location/route.tsx b/src/app/api/location/route.tsx
index 452a85d..bc4cfff 100644
--- a/src/app/api/location/route.tsx
+++ b/src/app/api/location/route.tsx
@@ -1,17 +1,14 @@
+import getServerCredential from "@/common/libs/getServerCredential";
 import { NextRequest, NextResponse } from "next/server";
 import { prisma } from "prisma/client";
-import { Credential } from "@/common/types/auth"
 
 export async function GET(request: NextRequest) {
   const searchParams = request.nextUrl.searchParams;
   const search = searchParams.get('search');
 
-  const credentialStr = request.cookies.get('credential')?.value
-  const credential: Credential | null = credentialStr ? JSON.parse(credentialStr) : null
+  const credential = getServerCredential()
 
-  if (!credential) {
-    return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
-  }
+  if (!credential) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
 
   const { companyId } = credential
 
-- 
cgit v1.2.3

