From 439e74b31a391a3edf6d4e4351417c72d01fb1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Caldana=20Anelli?= Date: Thu, 19 Dec 2024 09:49:25 -0300 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20adi=C3=A7=C3=A3o=20de=20installment?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/buy-together/BuyTogetherQueries.ts | 1 + src/modules/buy-together/BuyTogetherTypes.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/buy-together/BuyTogetherQueries.ts b/src/modules/buy-together/BuyTogetherQueries.ts index fffe59a..881615c 100644 --- a/src/modules/buy-together/BuyTogetherQueries.ts +++ b/src/modules/buy-together/BuyTogetherQueries.ts @@ -72,6 +72,7 @@ export class BuyTogetherQueries { markup isDefault installment ${installmentFields} + installments ${installmentFields} }` const featureFields = ` { diff --git a/src/modules/buy-together/BuyTogetherTypes.ts b/src/modules/buy-together/BuyTogetherTypes.ts index c18a957..ef3f550 100644 --- a/src/modules/buy-together/BuyTogetherTypes.ts +++ b/src/modules/buy-together/BuyTogetherTypes.ts @@ -33,7 +33,7 @@ export interface PaymentInstallment { discount: number interest: number total: string - parcel_price: string + parcelPrice: string } export interface Payment { From bd548eb5698fb21a2061183a6562b7c16f4d7011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Caldana=20Anelli?= Date: Thu, 19 Dec 2024 11:09:53 -0300 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20adiciona=20m=C3=A9todo=20de=20busca?= =?UTF-8?q?=20por=20slug=20na=20api-storefront?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app/AppRepositoryGql.ts | 8 ++++++++ src/modules/app/AppRepositoryJson.ts | 18 ++++++++++++++++++ src/modules/app/AppService.ts | 11 +++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/modules/app/AppRepositoryGql.ts b/src/modules/app/AppRepositoryGql.ts index 07f7608..deb5272 100644 --- a/src/modules/app/AppRepositoryGql.ts +++ b/src/modules/app/AppRepositoryGql.ts @@ -10,4 +10,12 @@ export class AppRepositoryGql { return app } + + static async getBySlug(slug: string, fields?: AppFields[]): Promise { + const appQuery = new AppQueries(fields) + const getAppQuery: string = appQuery.getApp() + const { app }: AppResponse = await getClient().query(getAppQuery, { filter: { slug: slug } }) + + return app + } } diff --git a/src/modules/app/AppRepositoryJson.ts b/src/modules/app/AppRepositoryJson.ts index 8e1b213..32b9fc3 100644 --- a/src/modules/app/AppRepositoryJson.ts +++ b/src/modules/app/AppRepositoryJson.ts @@ -18,4 +18,22 @@ export class AppRepositoryJson { return mock } + + static async getBySlug(slug: string, fields?: AppFields[]) { + const mock = shop_ctx.mock?.apps || {} + + if (slug != mock.slug) { + throw new Error('apps_not_found') + } + + const isFieldNotSelected = entry => !fields.includes(entry) + + const deleteFieldIfNecessary = entry => { + isFieldNotSelected(entry) && delete mock[entry] + } + + fields && Object.keys(mock).forEach(deleteFieldIfNecessary) + + return mock + } } diff --git a/src/modules/app/AppService.ts b/src/modules/app/AppService.ts index a2314c2..583efec 100644 --- a/src/modules/app/AppService.ts +++ b/src/modules/app/AppService.ts @@ -16,4 +16,15 @@ export class AppService { throw new Error(error?.message) } } + + static async getBySlug(slug: string, fields?: AppFields[]): Promise { + try { + const result = await Repository().getBySlug(slug, fields) + BroadcastService.emit('Apps', result) + + return result + } catch (error) { + throw new Error(error?.message) + } + } }