This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { toAdminInventoryImageDto } from '@pokemon-inventory/contracts/image';
|
||||
import { createInventoryImageSchema, moveInventoryImageSchema } from '@pokemon-inventory/validation/image';
|
||||
import { createInventoryImageSchema, moveInventoryImageSchema, updateImageOrderSchema, updateImageAltTextSchema } from '@pokemon-inventory/validation/image';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
import { createApplicationError } from '../../../shared/errors/application-error.js';
|
||||
@@ -110,11 +110,13 @@ export async function registerAdminImageRoutes(app, options) {
|
||||
return { data: toAdminInventoryImageDto(image) };
|
||||
});
|
||||
|
||||
app.patch('/images/:id/order', async (request) => {
|
||||
app.patch('/images/:id/order', async (request, reply) => {
|
||||
const admin = await authorizeAdminMutation(request);
|
||||
const result = updateImageOrderSchema.safeParse(request.body);
|
||||
if (!result.success) return validationError(reply, result);
|
||||
const image = await inventoryImageService.updateOrder({
|
||||
imageId: request.params.id,
|
||||
sortOrder: request.body?.sortOrder,
|
||||
sortOrder: result.data.sortOrder,
|
||||
sellerId: admin.sellerId,
|
||||
});
|
||||
return { data: toAdminInventoryImageDto(image) };
|
||||
@@ -129,11 +131,13 @@ export async function registerAdminImageRoutes(app, options) {
|
||||
return { data: toAdminInventoryImageDto(image) };
|
||||
});
|
||||
|
||||
app.patch('/images/:id/alt-text', async (request) => {
|
||||
app.patch('/images/:id/alt-text', async (request, reply) => {
|
||||
const admin = await authorizeAdminMutation(request);
|
||||
const result = updateImageAltTextSchema.safeParse(request.body);
|
||||
if (!result.success) return validationError(reply, result);
|
||||
const image = await inventoryImageService.updateAltText({
|
||||
imageId: request.params.id,
|
||||
altText: request.body?.altText ?? null,
|
||||
altText: result.data.altText,
|
||||
sellerId: admin.sellerId,
|
||||
});
|
||||
return { data: toAdminInventoryImageDto(image) };
|
||||
|
||||
Reference in New Issue
Block a user