Pixel editing.

This commit is contained in:
Mike Cao 2025-08-15 13:04:13 -07:00
parent eabdd18604
commit d130242a0a
23 changed files with 72 additions and 49 deletions

View file

@ -25,7 +25,6 @@ export async function GET(request: Request, { params }: { params: Promise<{ pixe
export async function POST(request: Request, { params }: { params: Promise<{ pixelId: string }> }) {
const schema = z.object({
name: z.string(),
url: z.string().url(),
slug: z.string().min(8),
});
@ -36,14 +35,14 @@ export async function POST(request: Request, { params }: { params: Promise<{ pix
}
const { pixelId } = await params;
const { name, domain, shareId } = body;
const { name, slug } = body;
if (!(await canUpdatePixel(auth, pixelId))) {
return unauthorized();
}
try {
const pixel = await updatePixel(pixelId, { name, domain, shareId });
const pixel = await updatePixel(pixelId, { name, slug });
return Response.json(pixel);
} catch (e: any) {

View file

@ -4,7 +4,7 @@ import { json, unauthorized } from '@/lib/response';
import { uuid } from '@/lib/crypto';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { pagingParams, searchParams } from '@/lib/schema';
import { createPixel, getUserLinks } from '@/queries';
import { createPixel, getUserPixels } from '@/queries';
export async function GET(request: Request) {
const schema = z.object({
@ -20,7 +20,7 @@ export async function GET(request: Request) {
const filters = await getQueryFilters(query);
const links = await getUserLinks(auth.user.id, filters);
const links = await getUserPixels(auth.user.id, filters);
return json(links);
}