This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { toAdminInventoryImageDto } from '@pokemon-inventory/contracts/image';
|
||||
import { createInventoryImageSchema } from '@pokemon-inventory/validation/image';
|
||||
import { createInventoryImageSchema, moveInventoryImageSchema } from '@pokemon-inventory/validation/image';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
import { createApplicationError } from '../../../shared/errors/application-error.js';
|
||||
@@ -98,6 +98,18 @@ export async function registerAdminImageRoutes(app, options) {
|
||||
return admin;
|
||||
}
|
||||
|
||||
app.post('/images/:id/move', async (request, reply) => {
|
||||
const admin = await authorizeAdminMutation(request);
|
||||
const result = moveInventoryImageSchema.safeParse(request.body);
|
||||
if (!result.success) return validationError(reply, result);
|
||||
const image = await inventoryImageService.move({
|
||||
imageId: request.params.id,
|
||||
direction: result.data.direction,
|
||||
sellerId: admin.sellerId,
|
||||
});
|
||||
return { data: toAdminInventoryImageDto(image) };
|
||||
});
|
||||
|
||||
app.patch('/images/:id/order', async (request) => {
|
||||
const admin = await authorizeAdminMutation(request);
|
||||
const image = await inventoryImageService.updateOrder({
|
||||
|
||||
Reference in New Issue
Block a user