diff --git a/.changeset/dull-planets-dance.md b/.changeset/dull-planets-dance.md new file mode 100644 index 0000000..efbd7c0 --- /dev/null +++ b/.changeset/dull-planets-dance.md @@ -0,0 +1,5 @@ +--- +"saleor-app-taxes": patch +--- + +Fix invalid response format in `order-calculate-taxes`. diff --git a/apps/taxes/src/modules/app/webhook-response.ts b/apps/taxes/src/modules/app/webhook-response.ts index 80a3db6..55cfd46 100644 --- a/apps/taxes/src/modules/app/webhook-response.ts +++ b/apps/taxes/src/modules/app/webhook-response.ts @@ -2,6 +2,11 @@ import { NextApiResponse } from "next"; import { Logger } from "pino"; import { createLogger } from "../../lib/logger"; +/* + * idea: distinguish between async and sync webhooks + * when sync webhooks, require passing the event and enforce the required response format using ctx.buildResponse + * when async webhooks, dont require anything + */ export class WebhookResponse { private logger: Logger; constructor(private res: NextApiResponse) { @@ -20,9 +25,6 @@ export class WebhookResponse { success(data?: any) { this.logger.debug({ data }, "success called with:"); - return this.res.status(200).json({ - status: 200, - data, - }); + return this.res.send(data); } } diff --git a/apps/taxes/src/modules/ui/country-select/country-select.tsx b/apps/taxes/src/modules/ui/country-select/country-select.tsx index 3c821a1..10e3243 100644 --- a/apps/taxes/src/modules/ui/country-select/country-select.tsx +++ b/apps/taxes/src/modules/ui/country-select/country-select.tsx @@ -37,7 +37,17 @@ export const CountrySelect = React.forwardRef((p: CountrySelectProps, ref) => { }) ?? null } getOptionLabel={(option) => option.label} - renderInput={(params) => } + renderInput={(params) => ( + + )} /> ); }); diff --git a/apps/taxes/src/pages/api/webhooks/order-calculate-taxes.ts b/apps/taxes/src/pages/api/webhooks/order-calculate-taxes.ts index ae1be5b..12b5fe6 100644 --- a/apps/taxes/src/pages/api/webhooks/order-calculate-taxes.ts +++ b/apps/taxes/src/pages/api/webhooks/order-calculate-taxes.ts @@ -66,7 +66,7 @@ export default orderCalculateTaxesSyncWebhook.createHandler(async (req, res, ctx const calculatedTaxes = await taxProvider.calculateTaxes(payload.taxBase); logger.info({ calculatedTaxes }, "Taxes calculated"); - return webhookResponse.success(calculatedTaxes); + return webhookResponse.success(ctx.buildResponse(calculatedTaxes)); } catch (error) { return webhookResponse.failureRetry("Error while calculating taxes"); }