From e8fa9bd7bba125a339f11876eb5ea99d0cd301b6 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 25 May 2023 19:11:31 -0600 Subject: Añade historial de órdenes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clients/actions.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/clients/actions.ts') diff --git a/src/clients/actions.ts b/src/clients/actions.ts index bd99519..447d054 100644 --- a/src/clients/actions.ts +++ b/src/clients/actions.ts @@ -111,4 +111,17 @@ export async function deleteFromCart({ request }) { } return req.status; +} + +export async function placeOrder({ request }) { + const client = new ApiClient(); + const form = await request.formData(); + + try { + const response = await client.post('/orders', form, client.authorizationHeaders()); + + return redirect('/products'); + } catch(error) { + return redirect('/account/cart') + } } \ No newline at end of file -- cgit v1.2.3