Fixed functions
This commit is contained in:
parent
a9c0ae95a1
commit
ee16b63d90
3 changed files with 15 additions and 11 deletions
|
|
@ -1,17 +1,9 @@
|
||||||
import {createClient} from "@/lib/supabase/server";
|
import {createClient} from "@/lib/supabase/server";
|
||||||
import {NextResponse} from "next/server";
|
import {NextResponse} from "next/server";
|
||||||
|
import getUserByUUID from "@/lib/api/helpers/getUserByUUID";
|
||||||
|
|
||||||
// Helper function to get user data by UUID
|
// Helper function to get user data by UUID
|
||||||
export async function getUserByUUID(supabase: any, uuid: string) {
|
|
||||||
const {data: userData, error: userError} = await supabase
|
|
||||||
.from('users')
|
|
||||||
.select('*')
|
|
||||||
.eq('uuid', uuid)
|
|
||||||
.single();
|
|
||||||
|
|
||||||
if (userError) throw userError;
|
|
||||||
return userData;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {createClient} from "@/lib/supabase/server";
|
import {createClient} from "@/lib/supabase/server";
|
||||||
import {NextResponse} from "next/server";
|
import {NextResponse} from "next/server";
|
||||||
import {SupabaseClient} from "@supabase/supabase-js";
|
import {SupabaseClient} from "@supabase/supabase-js";
|
||||||
import {getUserByUUID} from "@/app/api/auth/get_user/route";
|
import getUserByUUID from "@/lib/api/helpers/getUserByUUID";
|
||||||
|
|
||||||
async function updateUserRequests(searchTerm: string, requestSuuid: string, supabase: SupabaseClient<any, "public", any>) {
|
async function updateUserRequests(searchTerm: string, requestSuuid: string, supabase: SupabaseClient<any, "public", any>) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
12
src/lib/api/helpers/getUserByUUID.ts
Normal file
12
src/lib/api/helpers/getUserByUUID.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import {SupabaseClient} from "@supabase/supabase-js";
|
||||||
|
|
||||||
|
export default async function getUserByUUID(supabase: SupabaseClient<any, "public", any>, uuid: string) {
|
||||||
|
const {data: userData, error: userError} = await supabase
|
||||||
|
.from('users')
|
||||||
|
.select('*')
|
||||||
|
.eq('uuid', uuid)
|
||||||
|
.single();
|
||||||
|
|
||||||
|
if (userError) throw userError;
|
||||||
|
return userData;
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue