Skip to content

Commit

Permalink
fix start and stop functionallity in shmo testing component
Browse files Browse the repository at this point in the history
  • Loading branch information
md committed Jan 13, 2025
1 parent 8670332 commit fdbb617
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/api/types/mobility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const InitShmoOneStopBookingRequestBodySchema = z.object({
.string()
.optional()
.describe('This is the same id as vehicleId from the mobility API'),
operatorId: z.string(),
});

export type InitShmoOneStopBookingRequestBody = z.infer<
Expand Down
33 changes: 23 additions & 10 deletions src/components/map/components/mobility/ShmoTesting.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React, {useEffect} from 'react';
import {
InitShmoOneStopBookingRequestBody,
ShmoBookingEvent,
Expand All @@ -17,17 +18,20 @@ import {useWindowDimensions, View} from 'react-native';
import {Button} from '@atb/components/button';
import {ScrollView} from 'react-native-gesture-handler';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import {useVehicle} from '@atb/mobility/use-vehicle';

type ShmoTestingProps = {selectedVehicleId?: string};

export const ShmoTesting = ({selectedVehicleId}: ShmoTestingProps) => {
const [previousBookingId, setPreviousBookingId] = useState<string>();
const [vehicleId, setVehicleId] = useState<string>();
const [vehicleId, setVehicleId] = useState<string>(selectedVehicleId ?? '');

const {theme} = useThemeContext();
const interactiveColor = theme.color.interactive[2];
const destructiveColor = theme.color.interactive.destructive;

const {operatorId} = useVehicle(vehicleId ?? '');

const styles = useStyles();
const {height: windowHeight} = useWindowDimensions();
const {top: safeAreaTop} = useSafeAreaInsets();
Expand All @@ -46,6 +50,12 @@ export const ShmoTesting = ({selectedVehicleId}: ShmoTestingProps) => {
const {data: activeShmoBooking} = useActiveShmoBookingQuery();
const {data: shmoBooking} = useShmoBookingQuery(previousBookingId);

useEffect(() => {
if (selectedVehicleId) {
setVehicleId(selectedVehicleId);
}
}, [selectedVehicleId]);

const {
mutateAsync: getIdsFromQrCode,
isLoading: getIdsFromQrCodeIsLoading,
Expand All @@ -66,23 +76,24 @@ export const ShmoTesting = ({selectedVehicleId}: ShmoTestingProps) => {

const getVehicleIdFromQrCode = async () => {
const idsFromQrCode = await getIdsFromQrCode({
qrCodeUrl: 'https://m.ryde.vip/scooter.html?n=154197',
qrCodeUrl: 'https://m.ryde.vip/scooter.html?n=146030',
latitude: 0,
longitude: 0,
});
return idsFromQrCode.vehicleId;
};

const initShmoBooking = useCallback(() => {
if (!!recurringPaymentId && !!selectedVehicleId) {
if (!!recurringPaymentId && !!vehicleId) {
const initReqBody: InitShmoOneStopBookingRequestBody = {
recurringPaymentId,
coordinates: {latitude: 0, longitude: 0},
assetId: selectedVehicleId,
assetId: vehicleId,
operatorId: operatorId ?? 'YRY:Operator:Ryde',
};
initShmoOneStopBooking(initReqBody);
}
}, [recurringPaymentId, initShmoOneStopBooking, selectedVehicleId]);
}, [recurringPaymentId, initShmoOneStopBooking, vehicleId, operatorId]);

const startFinishingShmoBooking = useCallback(() => {
if (activeShmoBooking?.bookingId) {
Expand All @@ -102,7 +113,8 @@ export const ShmoTesting = ({selectedVehicleId}: ShmoTestingProps) => {
event: ShmoBookingEventType.FINISH,
fileName: 'evidence.png',
fileType: 'image/png',
fileData: 'c2FkZmRzZmFzZmJ2Cg==',
fileData:
'/9j/4AAQSkZJRgABAQEASABIAAD/4QW5RXhpZgAASUkqAAgAAAAMAAABBAABAAAAwA8AAAEBBAABAAAA0AsAAA8BAgAIAAAAngAAABABAgAJAAAApgAAABIBAwABAAAAAQAAABoBBQABAAAA0gAAABsBBQABAAAA2gAAACgBAwABAAAAAgAAADEBAgAOAAAAsAAAADIBAgAUAAAAvgAAABMCAwABAAAAAQAAAGmHBAABAAAA4gAAAKwCAABzYW1zdW5nAFNNLUc5OTFCAABHOTkxQlhYVTRDVkQyADIwMjI6MDU6MTQgMTU6MzU6MzgASAAAAAEAAABIAAAAAQAAABoAmoIFAAEAAABgAgAAnYIFAAEAAABYAgAAIogD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3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDr3VA7ARxYz/zzH+FFFFZcz7mnKux//9k=',
};
sendShmoBookingEvent({
bookingId: activeShmoBooking?.bookingId,
Expand Down Expand Up @@ -196,7 +208,7 @@ export const ShmoTesting = ({selectedVehicleId}: ShmoTestingProps) => {
style={{
position: 'absolute',
left: 0,
width: '50%',
width: '35%',
paddingTop: safeAreaTop,
}}
>
Expand All @@ -211,10 +223,11 @@ export const ShmoTesting = ({selectedVehicleId}: ShmoTestingProps) => {
<ThemeText>RecurringPaymentId: {recurringPaymentId}</ThemeText>

<View style={{backgroundColor: 'rgba(0,255,0,0.25)'}}>
<ThemeText>VehicleId: {selectedVehicleId}</ThemeText>
<ThemeText>VehicleId: {vehicleId}</ThemeText>
</View>
<View style={{backgroundColor: 'rgba(100,100,100,0.25)'}}>
<ThemeText>VehicleIdFromQr: {vehicleId}</ThemeText>

<View style={{backgroundColor: 'yellow'}}>
<ThemeText>OperatorId: {operatorId}</ThemeText>
</View>

<View style={{backgroundColor: 'rgba(0,0,255,0.25)'}}>
Expand Down

0 comments on commit fdbb617

Please sign in to comment.