Skip to content
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
48 changes: 27 additions & 21 deletions src/flows/ContractorOnboarding/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,25 +350,27 @@ const useEorSubscription = (options?: { enabled?: boolean }) => {
(plan) => plan.product.name === 'EOR Monthly',
);

const eorSubscription = {
product: {
identifier: eorProductIdentifier,
short_name: 'EOR',
},
currency: eorPricingPlan?.price.currency,
price: {
amount: convertFromCents(eorPricingPlan?.price.amount ?? 0),
},
features: [
'Contract between Remote and employee',
'Remote manages onboarding, payroll, and compliance',
'Manages taxes, benefits, and time-off tracking',
'Handles contracts, transfers, and terminations',
],
description: 'Enables hiring in countries without a local entity',
label: 'Employer of Record',
value: eorProductIdentifier,
};
const eorSubscription = eorPricingPlan
? {
product: {
identifier: eorProductIdentifier,
short_name: 'EOR',
},
currency: eorPricingPlan.price.currency,
price: {
amount: convertFromCents(eorPricingPlan.price.amount),
},
features: [
'Contract between Remote and employee',
'Remote manages onboarding, payroll, and compliance',
'Manages taxes, benefits, and time-off tracking',
'Handles contracts, transfers, and terminations',
],
description: 'Enables hiring in countries without a local entity',
label: 'Employer of Record',
value: eorProductIdentifier,
}
: null;

return { eorSubscription, isLoading: isLoadingPricingPlans };
};
Expand All @@ -384,7 +386,10 @@ const addEorToFieldOptions = (
eorSubscription: ReturnType<typeof useEorSubscription>['eorSubscription'],
excludeProducts?: ProductType[],
) => {
if (shouldIncludeProduct(eorProductIdentifier, excludeProducts)) {
if (
eorSubscription &&
shouldIncludeProduct(eorProductIdentifier, excludeProducts)
) {
Comment thread
cursor[bot] marked this conversation as resolved.
fieldOptions.push({
label: eorSubscription.label,
value: eorSubscription.value,
Expand Down Expand Up @@ -457,7 +462,8 @@ export const useContractorSubscriptionSchemaField = (
});

const hasAvailableOptions =
filteredContractorSubscriptions.length > 0 || showEorSubscription;
filteredContractorSubscriptions.length > 0 ||
(showEorSubscription && eorSubscription !== null);

const form = createHeadlessForm(
selectContractorSubscriptionStepSchema.data.schema,
Expand Down
56 changes: 56 additions & 0 deletions src/flows/ContractorOnboarding/tests/ContractorOnboarding.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,62 @@ describe('ContractorOnboardingFlow', () => {
expect(eorOption).toBeChecked();
});
});

it('should not show Employer of Record option when pricing plans is empty', async () => {
server.use(
http.get('*/v1/countries', () => {
return HttpResponse.json({
data: [
{
code: 'PRT',
name: 'Portugal',
eor_onboarding: true,
},
],
});
}),
http.get(
'*/v1/contractors/employments/*/contractor-subscriptions',
() => {
return HttpResponse.json(mockCMOnlyResponse);
},
),
http.get('*/v1/companies/*/pricing-plans', () => {
return HttpResponse.json({
data: {
pricing_plans: [],
},
});
}),
);

mockRender.mockImplementation(
createMockRenderImplementation(MultiStepFormWithoutCountry),
);

render(
<ContractorOnboardingFlow
{...defaultProps}
countryCode='PRT'
skipSteps={['select_country']}
/>,
{ wrapper: TestProviders },
);

await screen.findByText(/Step: Basic Information/i);
await fillBasicInformation();

const nextButton = screen.getByText(/Next Step/i);
nextButton.click();

await screen.findByText(/Step: Pricing Plan/i);
await waitForElementToBeRemoved(() => screen.getByTestId('spinner'));

const eorOption = screen.queryByRole('radio', {
name: /Employer of Record/i,
});
expect(eorOption).not.toBeInTheDocument();
});
});

describe('COR Contract Preview Skip', () => {
Expand Down
Loading