From 5895bbfe14de8cbd566e4a418325339d629b4c26 Mon Sep 17 00:00:00 2001
From: Omer Gery <68545675+OmerGery@users.noreply.github.com>
Date: Wed, 10 Jan 2024 09:09:03 +0200
Subject: [PATCH] add empty state for services and choose payment
---
.../src/Components/EmptyState/index.tsx | 26 +++++++++++
.../src/Components/EmptyState/styled.ts | 42 +++++++++++++++++
examples/client/Locomotion/src/I18n/en.json | 5 +++
.../RideOptions/ServiceOptions/index.js | 24 +++++++---
.../src/popups/ChoosePaymentMethod/index.tsx | 45 +++++++++++--------
5 files changed, 117 insertions(+), 25 deletions(-)
create mode 100644 examples/client/Locomotion/src/Components/EmptyState/index.tsx
create mode 100644 examples/client/Locomotion/src/Components/EmptyState/styled.ts
diff --git a/examples/client/Locomotion/src/Components/EmptyState/index.tsx b/examples/client/Locomotion/src/Components/EmptyState/index.tsx
new file mode 100644
index 000000000..998270cca
--- /dev/null
+++ b/examples/client/Locomotion/src/Components/EmptyState/index.tsx
@@ -0,0 +1,26 @@
+import React from 'react';
+import {
+ Container, Description, Title, TitleWithoutDescription,
+} from './styled';
+
+interface EmptyStateProps {
+ title: string;
+ description?: string;
+}
+const EmptyState = ({
+ title,
+ description,
+}: EmptyStateProps) => (
+
+ {description
+ ? {title}
+ : {title}
+ }
+
+ {description ? {description} : null}
+
+);
+EmptyState.defaultProps = {
+ description: '',
+};
+export default EmptyState;
diff --git a/examples/client/Locomotion/src/Components/EmptyState/styled.ts b/examples/client/Locomotion/src/Components/EmptyState/styled.ts
new file mode 100644
index 000000000..7d5ed2e74
--- /dev/null
+++ b/examples/client/Locomotion/src/Components/EmptyState/styled.ts
@@ -0,0 +1,42 @@
+import { Text, View } from 'react-native';
+import styled from 'styled-components';
+
+export const Container = styled(View)`
+border-radius: 8px;
+border: 1px dashed rgba(125, 139, 172, 0.32);
+display: flex;
+padding: 16px;
+flex-direction: column;
+justify-content: center;
+align-items: center;
+margin: 4px;
+flex: 1 0 0;
+align-self: stretch;
+`;
+export const Title = styled(Text)`
+align-self: stretch;
+color: #212229;
+text-align: center;
+font-family: Inter;
+font-size: 14px;
+font-style: normal;
+font-weight: 600;
+`;
+export const Description = styled(Text)`
+align-self: stretch;
+color: #666975;
+text-align: center;
+font-family: Inter;
+font-size: 14px;
+font-style: normal;
+font-weight: 400;
+`;
+export const TitleWithoutDescription = styled(Text)`
+align-self: stretch;
+color: #666975;
+text-align: center;
+font-family: Inter;
+font-size: 14px;
+font-style: normal;
+font-weight: 500;
+`;
diff --git a/examples/client/Locomotion/src/I18n/en.json b/examples/client/Locomotion/src/I18n/en.json
index 50eca14ab..56d4da2f4 100644
--- a/examples/client/Locomotion/src/I18n/en.json
+++ b/examples/client/Locomotion/src/I18n/en.json
@@ -45,6 +45,10 @@
"tags": {
"fastest": "Fastest",
"cheapest": "Cheapest"
+ },
+ "emptyState": {
+ "title": "There are no available services",
+ "description": "Try changing the ride schedule or select a different payment method"
}
},
"rideDetails": {
@@ -290,6 +294,7 @@
"save": "Save",
"cancel": "Cancel",
"unavailable": "Unavailable for the selected service",
+ "emptyStateText": "No credit cards were added",
"tabs": {
"personal": "Personal",
"business": "Business"
diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/ServiceOptions/index.js b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/ServiceOptions/index.js
index 77bc73bd7..7c2d93376 100644
--- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/ServiceOptions/index.js
+++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/ServiceOptions/index.js
@@ -1,6 +1,7 @@
import React, { useContext, useEffect } from 'react';
import SkeletonContent from 'react-native-skeleton-content-nonexpo';
import { Text } from 'react-native';
+import EmptyState from '../../../../../Components/EmptyState';
import { getCouponText } from '../../../../../context/newRideContext/utils';
import { RidePageContext } from '../../../../../context/newRideContext';
import { UserContext } from '../../../../../context/user';
@@ -55,13 +56,22 @@ const ServiceOptions = () => {
return (
- {(serviceEstimations || []).map(option => (
-
- ))}
+
+ { serviceEstimations?.length === 0
+ ? (
+
+ )
+ : (serviceEstimations || []).map(option => (
+
+ ))
+ }
{!isDebuggingEnabled
? (
(
+ personalPaymentMethods.length > 0
+ ? (personalPaymentMethods.map((paymentMethod: any) => {
+ const reason = getDisabledReason(paymentMethod);
+ return (
+ {
+ setSelectedPaymentId(paymentMethod.id);
+ }}
+ />
+ );
+ })
+ ) : (
+
+ )
+ );
+
return (
);
})
- ) : (
- personalPaymentMethods.map((paymentMethod: any) => {
- const reason = getDisabledReason(paymentMethod);
- return (
- {
- setSelectedPaymentId(paymentMethod.id);
- }}
- />
- );
- })
- )}
+ ) : renderPersonalPaymentMethods()}
{ !isBusinessMode && (