diff --git a/backend/.tmp/dev.data.db b/backend/.tmp/dev.data.db index 228174c..fd7fc20 100644 Binary files a/backend/.tmp/dev.data.db and b/backend/.tmp/dev.data.db differ diff --git a/backend/src/api/order/content-types/order/schema.json b/backend/src/api/order/content-types/order/schema.json index 21c49cd..72293f7 100644 --- a/backend/src/api/order/content-types/order/schema.json +++ b/backend/src/api/order/content-types/order/schema.json @@ -31,6 +31,9 @@ }, "notes": { "type": "text" + }, + "last_confirmed_at": { + "type": "datetime" } } } diff --git a/backend/src/api/order/controllers/order.ts b/backend/src/api/order/controllers/order.ts index be05ed8..dc51db6 100644 --- a/backend/src/api/order/controllers/order.ts +++ b/backend/src/api/order/controllers/order.ts @@ -35,6 +35,21 @@ export default factories.createCoreController('api::order.order', { } }) + return order + }, + async confirm(ctx, next) { + strapi.log.info('confirm', ctx.params) + let orderId = ctx.params.id + if (!orderId) { + return ctx.badRequest('Missing or invalid id', { orderId }) + } + + let order = await strapi.entityService.update('api::order.order', orderId, { + data: { + last_confirmed_at: new Date() + } + }) + return order } }) diff --git a/backend/src/api/order/routes/custom.ts b/backend/src/api/order/routes/custom.ts index 562b4db..4f2a41b 100644 --- a/backend/src/api/order/routes/custom.ts +++ b/backend/src/api/order/routes/custom.ts @@ -7,6 +7,14 @@ export default { config: { auth: false } + }, + { + method: 'POST', + path: '/orders/:id/confirm', + handler: 'order.confirm', + config: { + auth: false + } } ] } diff --git a/backend/src/api/sale/controllers/sale.ts b/backend/src/api/sale/controllers/sale.ts index b5dd8e7..5eca9d6 100644 --- a/backend/src/api/sale/controllers/sale.ts +++ b/backend/src/api/sale/controllers/sale.ts @@ -99,6 +99,7 @@ export default factories.createCoreController('api::sale.sale', { let ordersWithOneItem = orders.filter((order) => { // returning only the orders that have at least one item + console.log("order", order.id); let order_items = order.order_items.filter((order_item) => { // checking if there is at least one order item with quantity > 0 return order_item.quantity > 0 diff --git a/backend/types/generated/contentTypes.d.ts b/backend/types/generated/contentTypes.d.ts index 5020cff..60aed95 100644 --- a/backend/types/generated/contentTypes.d.ts +++ b/backend/types/generated/contentTypes.d.ts @@ -697,6 +697,7 @@ export interface ApiOrderOrder extends Schema.CollectionType { sale: Attribute.Relation<'api::order.order', 'manyToOne', 'api::sale.sale'> order_items: Attribute.Relation<'api::order.order', 'oneToMany', 'api::order-item.order-item'> notes: Attribute.Text + last_confirmed_at: Attribute.DateTime createdAt: Attribute.DateTime updatedAt: Attribute.DateTime createdBy: Attribute.Relation<'api::order.order', 'oneToOne', 'admin::user'> & Attribute.Private diff --git a/frontend/pages/order/[shop]/[client].vue b/frontend/pages/order/[shop]/[client].vue index 3e18573..6ab2e5e 100644 --- a/frontend/pages/order/[shop]/[client].vue +++ b/frontend/pages/order/[shop]/[client].vue @@ -1,12 +1,16 @@