Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] Adicionar exibição de pagamentos #148

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/modules/app/AppRepositoryGql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ export class AppRepositoryGql {

return app
}

static async getBySlug(slug: string, fields?: AppFields[]): Promise<App> {
const appQuery = new AppQueries(fields)
const getAppQuery: string = appQuery.getApp()
const { app }: AppResponse = await getClient().query(getAppQuery, { filter: { slug: slug } })

return app
}
}
18 changes: 18 additions & 0 deletions src/modules/app/AppRepositoryJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
11 changes: 11 additions & 0 deletions src/modules/app/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ export class AppService {
throw new Error(error?.message)
}
}

static async getBySlug(slug: string, fields?: AppFields[]): Promise<App> {
try {
const result = await Repository().getBySlug(slug, fields)
BroadcastService.emit('Apps', result)

return result
} catch (error) {
throw new Error(error?.message)
}
}
}
1 change: 1 addition & 0 deletions src/modules/buy-together/BuyTogetherQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class BuyTogetherQueries {
markup
isDefault
installment ${installmentFields}
installments ${installmentFields}
}`
const featureFields = `
{
Expand Down
2 changes: 1 addition & 1 deletion src/modules/buy-together/BuyTogetherTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface PaymentInstallment {
discount: number
interest: number
total: string
parcel_price: string
parcelPrice: string
}

export interface Payment {
Expand Down
Loading