import React from 'react'
import { useLanguage, useUtils, useConfig } from 'ordering-components/native'
import { OButton, OText } from '../shared'
import { ActiveOrdersContainer, Card, Information, OrderInformation, BusinessInformation, Price } from './styles'
import { Platform, StyleSheet } from 'react-native'
import { ActiveOrdersParams } from '../../types'
import { useWindowDimensions } from 'react-native'
import { useTheme } from 'styled-components/native'
export const ActiveOrders = (props: ActiveOrdersParams) => {
const {
onNavigationRedirect,
orders,
pagination,
loadMoreOrders,
getOrderStatus,
padding
} = props
const theme = useTheme();
const { width } = useWindowDimensions();
const [{ configs }] = useConfig()
const [, t] = useLanguage()
const [{ parseDate, parsePrice, optimizeImage }] = useUtils()
const handleClickCard = (uuid: string) => {
onNavigationRedirect && onNavigationRedirect('OrderDetails', { orderId: uuid })
}
const Order = ({ order, index }: { order: any, index: number }) => (
handleClickCard(order?.uuid)}
style={{ width: width * 0.9 - (padding || 0) * 2 }}
>
{order.business?.name}
{order?.delivery_datetime_utc
? parseDate(order?.delivery_datetime_utc)
: parseDate(order?.delivery_datetime, { utc: false })}
{`${t('ORDER_NUMBER', 'Order No.')} ${order.id}`}
{parsePrice(order?.summary?.total || order?.total)}
{order?.status !== 0 && (
{getOrderStatus(order.status)?.value}
)}
{pagination?.totalPages && pagination?.currentPage < pagination?.totalPages && index === (10 * pagination?.currentPage) - 1 && (
)}
)
return (
{orders.length > 0 && (
orders.map((order: any, index: any) => (
))
)}
)
}
const styles = StyleSheet.create({
logo: {
borderRadius: 10,
width: 75,
height: '100%'
},
orderNumber: {
flexDirection: 'row'
},
loadOrders: {
justifyContent: 'center',
alignItems: 'center',
minWidth: 169,
borderWidth: 0,
}
})