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

Aut 18615 switch demand source #807

Merged
merged 9 commits into from
Feb 12, 2024
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
21 changes: 20 additions & 1 deletion examples/client/Locomotion/src/context/user/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,32 @@ const UserContextProvider = ({ children }: { children: any }) => {
return vertResponse.status === 'OK';
};

const getAllowedDemandSourceIds = (): string[] => {
try {
if (!Config.ALLOWED_DEMAND_SOURCE_IDS) {
return [];
}
const allowedDemandSourceIds = JSON.parse(Config.ALLOWED_DEMAND_SOURCE_IDS);
return Array.isArray(allowedDemandSourceIds) ? allowedDemandSourceIds : [];
} catch (error) {
Mixpanel.setEvent('Invalid ALLOWED_DEMAND_SOURCE_IDS', { allowedDemandSourceIds: Config.ALLOWED_DEMAND_SOURCE_IDS });
return [];
}
};

const onLogin = async (phoneNumber: string, channel = 'sms') => {
const demandSourceId = await AppSettings.getOperationId();
await loginApi({
const allowedDemandSourceIds = getAllowedDemandSourceIds();
const response = await loginApi({
phoneNumber,
channel,
demandSourceId,
allowedDemandSourceIds,
});
Copy link
Contributor

@OmerGery OmerGery Feb 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { demandSourceId: responseDemandSourceId } = response;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it's selectedDemandSourceId, so no need to rename

const { selectedDemandSourceId } = response;
if (allowedDemandSourceIds.length > 0 && selectedDemandSourceId && selectedDemandSourceId !== demandSourceId) {
await AppSettings.setOperationId(selectedDemandSourceId);
}
// successful login - delete captcha token
await StorageService.delete('captchaToken');
};
Expand Down
1 change: 1 addition & 0 deletions examples/client/Locomotion/src/services/app-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const AppSettings = {
},
});
},
setOperationId: async newOperationId => AppSettings.setSettings({ operationId: newOperationId }),
destroy: async () => Storage.clear(),
};

Expand Down
Loading