Skip to content

Commit

Permalink
removed price divide
Browse files Browse the repository at this point in the history
  • Loading branch information
tortuvshin committed Feb 20, 2024
1 parent 9558c8d commit 6f821ec
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 108 deletions.
14 changes: 5 additions & 9 deletions src/features/Account/screens/AccountScreen.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React, { useState, useEffect } from 'react';
import { View, Text, ImageBackground, Image, TouchableOpacity, ActivityIndicator, Dimensions } from 'react-native';
import { getUniqueId } from 'react-native-device-info';
import { EventRegister } from 'react-native-event-listeners';
import { faBox, faChevronRight, faIdBadge, faMapMarked, faUser } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faBox, faChevronRight, faLockOpen, faUser, faMapMarked, faCreditCard, faIdBadge } from '@fortawesome/free-solid-svg-icons';
import { useCustomer, signOut } from 'utils/Customer';
import { config, translate } from 'utils';
import { useLocale } from 'hooks';
import React, { useState } from 'react';
import { ActivityIndicator, Dimensions, ImageBackground, Text, TouchableOpacity, View } from 'react-native';
import FastImage from 'react-native-fast-image';
import StorefrontHeader from 'ui/headers/StorefrontHeader';
import NetworkHeader from 'ui/headers/NetworkHeader';
import tailwind from 'tailwind';
import { config, translate } from 'utils';
import { signOut, useCustomer } from 'utils/Customer';

const fullHeight = Dimensions.get('window').height;

Expand Down
2 changes: 1 addition & 1 deletion src/features/Account/screens/OrderHistoryScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const OrderHistoryScreen = ({ navigation, route }) => {
}

return customer
.getOrderHistory({ query, sort: '-created_at', limit: -1, ...params })
.getOrderHistory({ query, sort: 'created_at', limit: 25, ...params })
.then(pushOrders)
.then(resolve)
.catch(logError)
Expand Down
15 changes: 7 additions & 8 deletions src/features/Auth/screens/LoginScreen.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { faTimes } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { useCustomer, useLocale, useStorefront } from 'hooks';
import React, { useState } from 'react';
import { View, Text, ImageBackground, TouchableOpacity, TextInput, ActivityIndicator, Platform, KeyboardAvoidingView, Pressable, Keyboard } from 'react-native';
import { ActivityIndicator, ImageBackground, Keyboard, KeyboardAvoidingView, Platform, Pressable, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { getUniqueId } from 'react-native-device-info';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faTimes } from '@fortawesome/free-solid-svg-icons';
import { useStorefront, useLocale, useCustomer } from 'hooks';
import { logError, deepGet, translate, config } from 'utils';
import { getLocation } from 'utils/Geo';
import { set, get } from 'utils/Storage';
import tailwind from 'tailwind';
import PhoneInput from 'ui/PhoneInput';
import { config, logError, translate } from 'utils';
import { getLocation } from 'utils/Geo';
import { get } from 'utils/Storage';

const LoginScreen = ({ navigation, route }) => {
const { info, redirectTo } = route.params;
Expand Down
18 changes: 8 additions & 10 deletions src/features/Browser/screens/ProductScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ProductScreen = ({ navigation, route }) => {
: isInCart
? translate('Browser.ProductScreen.addAnotherActionText')
: translate('Browser.ProductScreen.addToCartActionText')
} - ${formatCurrency(subtotal / 100, product.getAttribute('currency'))}`;
} - ${formatCurrency(subtotal, product.getAttribute('currency'))}`;

if (isBookable) {
actionButtonText = `${
Expand All @@ -104,7 +104,7 @@ const ProductScreen = ({ navigation, route }) => {
: isInCart
? translate('Browser.ProductScreen.addAnotherBookingActionText')
: translate('Browser.ProductScreen.bookServiceActionText')
} - ${formatCurrency(subtotal / 100, product.getAttribute('currency'))}`;
} - ${formatCurrency(subtotal, product.getAttribute('currency'))}`;
}

const checkIfCanAddToCart = () => {
Expand Down Expand Up @@ -460,18 +460,16 @@ const ProductScreen = ({ navigation, route }) => {
<View style={tailwind('mb-2')}>
{product.isOnSale && (
<View style={tailwind('flex flex-row')}>
<Text style={tailwind('font-semibold text-xl mr-1')}>
{formatCurrency(product.getAttribute('sale_price') / 100, product.getAttribute('currency'))}
</Text>
<Text style={tailwind('font-semibold text-xl mr-1')}>{formatCurrency(product.getAttribute('sale_price'), product.getAttribute('currency'))}</Text>
<Text style={tailwind('line-through text-base text-gray-400')}>
{formatCurrency(product.getAttribute('price') / 100, product.getAttribute('currency'))}
{formatCurrency(product.getAttribute('price'), product.getAttribute('currency'))}
</Text>
</View>
)}
{!product.isOnSale && (
<View style={tailwind('flex flex-row')}>
<Text style={tailwind('text-center text-xl font-semibold')}>
{formatCurrency(product.getAttribute('price') / 100, product.getAttribute('currency'))}
{formatCurrency(product.getAttribute('price'), product.getAttribute('currency'))}
</Text>
</View>
)}
Expand Down Expand Up @@ -557,7 +555,7 @@ const ProductScreen = ({ navigation, route }) => {
<Text style={tailwind('text-sm text-gray-700')}>{variant.name}</Text>
</View>
<View>
<Text style={tailwind('text-gray-400')}>+{formatCurrency(variant.additional_cost / 100, product.getAttribute('currency'))}</Text>
<Text style={tailwind('text-gray-400')}>+{formatCurrency(variant.additional_cost, product.getAttribute('currency'))}</Text>
</View>
</View>
))}
Expand Down Expand Up @@ -593,11 +591,11 @@ const ProductScreen = ({ navigation, route }) => {
<View>
<View style={tailwind('flex flex-row')}>
<Text style={tailwind('text-gray-400')}>
+{formatCurrency((addon.is_on_sale ? addon.sale_price : addon.price) / 100, product.getAttribute('currency'))}
+{formatCurrency(addon.is_on_sale ? addon.sale_price : addon.price, product.getAttribute('currency'))}
</Text>
{addon.is_on_sale && (
<Text style={tailwind('ml-1 line-through text-base text-gray-300')}>
{formatCurrency(addon.price / 100, product.getAttribute('currency'))}
{formatCurrency(addon.price, product.getAttribute('currency'))}
</Text>
)}
</View>
Expand Down
14 changes: 7 additions & 7 deletions src/features/Cart/components/CartCheckoutPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const CartCheckoutPanel = ({ style, panelStyle, cart, total, serviceQuote, tip,
if (cart?.isEmpty) {
return <View />;
}

const navigation = useNavigation();
const [locale] = useLocale();

Expand All @@ -20,7 +20,7 @@ const CartCheckoutPanel = ({ style, panelStyle, cart, total, serviceQuote, tip,
<View style={tailwind('flex flex-row justify-between mb-2')}>
<View>
<Text style={tailwind('text-gray-400')}>{translate('Cart.components.CartCheckoutPanel.cartTotalLabelText')}</Text>
<Text style={tailwind('font-bold text-base')}>{formatCurrency(total / 100, cart.getAttribute('currency'))}</Text>
<Text style={tailwind('font-bold text-base')}>{formatCurrency(total, cart.getAttribute('currency'))}</Text>
</View>
<TouchableOpacity
disabled={isCheckoutDisabled}
Expand All @@ -34,14 +34,14 @@ const CartCheckoutPanel = ({ style, panelStyle, cart, total, serviceQuote, tip,
tipAmount: isTipping ? tip : 0,
deliveryTipAmount: isTippingDriver ? deliveryTip : 0,
})
}
>
}>
<View
style={tailwind(
`flex items-center justify-center rounded-md px-8 py-2 bg-white border border-green-600 ${isCheckoutDisabled ? 'bg-opacity-50 border-opacity-50' : ''}`
)}
>
<Text style={tailwind(`font-semibold text-green-600 text-lg ${isCheckoutDisabled ? 'text-opacity-50' : ''}`)}>{translate('Cart.components.CartCheckoutPanel.checkoutButtonText')}</Text>
)}>
<Text style={tailwind(`font-semibold text-green-600 text-lg ${isCheckoutDisabled ? 'text-opacity-50' : ''}`)}>
{translate('Cart.components.CartCheckoutPanel.checkoutButtonText')}
</Text>
</View>
</TouchableOpacity>
</View>
Expand Down
10 changes: 5 additions & 5 deletions src/features/Cart/components/CartFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { formatCurrency, translate } from 'utils';
import { useLocale } from 'hooks';
import tailwind from 'tailwind';

const capitalize = ([ first, ...rest ]) => `${first.toUpperCase()}${rest.join('')}`;
const capitalize = ([first, ...rest]) => `${first.toUpperCase()}${rest.join('')}`;

const CartFooter = (props) => {
const { style, cart, info, serviceQuote, isFetchingServiceQuote, serviceQuoteError, tip, deliveryTip, isTipping, isTippingDriver, isPickupOrder, isCheckoutDisabled, total } = props;
Expand Down Expand Up @@ -88,7 +88,7 @@ const CartFooter = (props) => {
</View>
{isTipping && (
<View style={tailwind('ml-2')}>
<TipInput value={tip} onChange={(tip, isPercent) => dispatch('setTip', (isPercent ? `${tip}%` : tip))} />
<TipInput value={tip} onChange={(tip, isPercent) => dispatch('setTip', isPercent ? `${tip}%` : tip)} />
</View>
)}
</View>
Expand All @@ -103,7 +103,7 @@ const CartFooter = (props) => {
trackColor={{ false: 'rgba(229, 231, 235, 1)', true: 'rgba(16, 185, 129, 1)' }}
thumbColor={'#f4f3f4'}
ios_backgroundColor="#3e3e3e"
onValueChange={() => dispatch('setIsTippingDriver', (!isTippingDriver))}
onValueChange={() => dispatch('setIsTippingDriver', !isTippingDriver)}
value={isTippingDriver}
style={{ transform: [{ scaleX: 0.8 }, { scaleY: 0.8 }] }}
/>
Expand All @@ -114,7 +114,7 @@ const CartFooter = (props) => {
</View>
{isTippingDriver && (
<View style={tailwind('ml-2')}>
<TipInput value={deliveryTip} onChange={(tip, isPercent) => dispatch('setDeliveryTip', (isPercent ? `${tip}%` : tip))} />
<TipInput value={deliveryTip} onChange={(tip, isPercent) => dispatch('setDeliveryTip', isPercent ? `${tip}%` : tip)} />
</View>
)}
</View>
Expand Down Expand Up @@ -177,7 +177,7 @@ const CartFooter = (props) => {
<Text style={tailwind('font-bold')}>{translate('Cart.components.CartFooter.cartTotalLabelText')}</Text>
</View>
<View>
<Text style={tailwind('font-bold')}>{formatCurrency(total / 100, cart.getAttribute('currency'))}</Text>
<Text style={tailwind('font-bold')}>{formatCurrency(total, cart.getAttribute('currency'))}</Text>
</View>
</View>
</View>
Expand Down
4 changes: 2 additions & 2 deletions src/features/Cart/screens/CartScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ const RenderCartItem = ({ item, index, cart, onEditCartItem, calculateCartItemRo
</View>
</View>
<View style={tailwind('flex items-end')}>
<Text style={tailwind('font-semibold text-sm')}>{formatCurrency(item.subtotal / 100, cart.getAttribute('currency'))}</Text>
<Text style={tailwind('font-semibold text-sm')}>{formatCurrency(item.subtotal, cart.getAttribute('currency'))}</Text>
{item.quantity > 1 && (
<View>
<Text numberOfLines={1} style={tailwind('text-gray-400 text-sm')}>
{translate('Cart.CartScreen.quantityExplenation', { cost: formatCurrency(item.subtotal / item.quantity / 100, cart.getAttribute('currency')) })}
{translate('Cart.CartScreen.quantityExplenation', { cost: formatCurrency(item.subtotal / item.quantity, cart.getAttribute('currency')) })}
</Text>
</View>
)}
Expand Down
20 changes: 10 additions & 10 deletions src/features/Cart/screens/CheckoutScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const CheckoutScreen = ({ navigation, route }) => {

if (!isFetchingServiceQuote && serviceQuote instanceof ServiceQuote) {
// deliveryFee = serviceQuote.formattedAmount;
deliveryFee = formatCurrency(serviceQuote.getAttribute('amount') / 100, cart.getAttribute('currency'));
deliveryFee = formatCurrency(serviceQuote.getAttribute('amount'), cart.getAttribute('currency'));
}

if (serviceQuoteError) {
Expand All @@ -147,21 +147,21 @@ const CheckoutScreen = ({ navigation, route }) => {
})();
const formattedTip = (() => {
if (typeof tip === 'string' && tip.endsWith('%')) {
const tipAmount = formatCurrency(calculatePercentage(parseInt(tip), cart.subtotal()) / 100, cart.getAttribute('currency'));
const tipAmount = formatCurrency(calculatePercentage(parseInt(tip), cart.subtotal()), cart.getAttribute('currency'));

return `${tip} (${tipAmount})`;
}

return formatCurrency(tip / 100, cart.getAttribute('currency'));
return formatCurrency(tip, cart.getAttribute('currency'));
})();
const formattedDeliveryTip = (() => {
if (typeof deliveryTip === 'string' && deliveryTip.endsWith('%')) {
const tipAmount = formatCurrency(calculatePercentage(parseInt(deliveryTip), cart.subtotal()) / 100, cart.getAttribute('currency'));
const tipAmount = formatCurrency(calculatePercentage(parseInt(deliveryTip), cart.subtotal()), cart.getAttribute('currency'));

return `${deliveryTip} (${tipAmount})`;
}

return formatCurrency(deliveryTip / 100, cart.getAttribute('currency'));
return formatCurrency(deliveryTip, cart.getAttribute('currency'));
})();

const openLink = async (url, errorMessage = null) => {
Expand Down Expand Up @@ -764,7 +764,7 @@ const CheckoutScreen = ({ navigation, route }) => {
{cartItem.name}
</Text>
<Text style={tailwind('text-center text-xs')} numberOfLines={1}>
x{cartItem.quantity} {formatCurrency(cartItem.subtotal / 100, cart.getAttribute('currency'))}
x{cartItem.quantity} {formatCurrency(cartItem.subtotal, cart.getAttribute('currency'))}
</Text>
</View>
))}
Expand All @@ -787,13 +787,13 @@ const CheckoutScreen = ({ navigation, route }) => {
<View style={tailwind('pb-40')}>
<View style={tailwind('flex flex-row items-center justify-between py-2')}>
<Text>{translate('Cart.CheckoutScreen.subtotalLabelText')}</Text>
<Text>{formatCurrency(cart.subtotal() / 100, cart.getAttribute('currency'))}</Text>
<Text>{formatCurrency(cart.subtotal(), cart.getAttribute('currency'))}</Text>
</View>
{!isPickupOrder && (
<View style={tailwind('flex flex-row items-center justify-between py-2')}>
<Text>{translate('Cart.CheckoutScreen.deliveryFeeLabelText')}</Text>
{/* <Text>{isFetchingServiceQuote ? <ActivityIndicator /> : serviceQuote.formattedAmount}</Text> */}
<Text>{isFetchingServiceQuote ? <ActivityIndicator /> : formatCurrency(serviceQuote.getAttribute('amount') / 100, cart.getAttribute('currency'))}</Text>
<Text>{isFetchingServiceQuote ? <ActivityIndicator /> : formatCurrency(serviceQuote.getAttribute('amount'), cart.getAttribute('currency'))}</Text>
</View>
)}
{tip !== 0 && (
Expand All @@ -810,7 +810,7 @@ const CheckoutScreen = ({ navigation, route }) => {
)}
<View style={tailwind('flex flex-row items-center justify-between mt-2 pt-4 border-t-2 border-gray-900')}>
<Text style={tailwind('font-semibold')}>{translate('Cart.CheckoutScreen.orderTotalLabelText')}</Text>
<Text style={tailwind('font-semibold')}>{formatCurrency(calculateTotal() / 100, cart.getAttribute('currency'))}</Text>
<Text style={tailwind('font-semibold')}>{formatCurrency(calculateTotal(), cart.getAttribute('currency'))}</Text>
</View>
</View>
</View>
Expand All @@ -821,7 +821,7 @@ const CheckoutScreen = ({ navigation, route }) => {
<View style={tailwind('flex flex-row justify-between mb-2')}>
<View>
<Text style={tailwind('text-gray-400')}>{translate('Cart.CheckoutScreen.orderTotalLabelText')}</Text>
<Text style={tailwind('font-bold text-base')}>{formatCurrency(calculateTotal() / 100, cart.getAttribute('currency'))}</Text>
<Text style={tailwind('font-bold text-base')}>{formatCurrency(calculateTotal(), cart.getAttribute('currency'))}</Text>
</View>
<TouchableOpacity onPress={placeOrder} disabled={!canPlaceOrder}>
<View
Expand Down
Loading

0 comments on commit 6f821ec

Please sign in to comment.