import React from 'react'
import {
BusinessInformation as BusinessInformationController,
useLanguage,
useConfig
} from 'ordering-components/native'
import { OText } from '../shared'
import {
BusinessInformationContainer,
WrapMainContent,
GrayBackground,
WrapScheduleBlock,
ScheduleBlock,
WrapBusinessMap,
InnerContent
} from './styles'
import { StyleSheet } from 'react-native'
import { BusinessBasicInformation } from '../BusinessBasicInformation'
import { BusinessInformationParams } from '../../types'
import { GoogleMap } from '../GoogleMap'
import { useTheme } from 'styled-components/native';
import moment from 'moment';
const BusinessInformationUI = (props: BusinessInformationParams) => {
const {
businessState,
businessSchedule,
businessLocation
} = props
const [, t] = useLanguage()
const theme = useTheme()
const [{ configs }] = useConfig();
const daysOfWeek = [
t('SUNDAY_ABBREVIATION', 'Sun'),
t('MONDAY_ABBREVIATION', 'Mon'),
t('TUESDAY_ABBREVIATION', 'Tues'),
t('WEDNESDAY_ABBREVIATION', 'Wed'),
t('THURSDAY_ABBREVIATION', 'Thur'),
t('FRIDAY_ABBREVIATION', 'Fri'),
t('SATURDAY_ABBREVIATION', 'Sat')
]
const formatTime = configs?.general_hour_format?.value
const checkTime = (val: number) => (val < 10 ? `0${val}` : val);
const timeFormated = (time: any) => {
return moment(`1900-01-01 ${checkTime(time.hour)}:${checkTime(time.minute)}`).format(formatTime)
}
return (
{(!!businessState?.business?.description) && (
<>
{t('BUSINESS_DESCRIPTION', 'Business description')}
{businessState?.business?.description}
>
)}
{(!!businessState?.business?.email || !!businessState?.business?.cellphone) && (
<>
{t('BUSINESS_DETAILS', 'Business Details')}
{!!businessState?.business?.email && (
{t('EMAIL', 'Email')}: {businessState?.business?.email}
)}
{!!businessState?.business?.cellphone && (
{t('CELLPHONE', 'Cellphone')}: {businessState?.business?.cellphone}
)}
>
)}
{t('BUSINESS_LOCATION', 'Business Location')}
{businessLocation.location && (
)}
{businessState?.business?.address}
{t('BUSINESS_OPENING_TIME', 'Business Opening Time')}
{businessSchedule && businessSchedule?.length > 0 && (
{businessSchedule.map((schedule: any, i: number) => (
{daysOfWeek[i]}
{schedule.enabled ? (
schedule.lapses.map( (time: any, k: number) => (
{timeFormated(time.open)}
{timeFormated(time.close)}
))) : ( {t('CLOSED', 'Closed')})}
))}
)}
)
}
const styles = StyleSheet.create({
wrapMapStyle: {
borderRadius: 10,
overflow: 'hidden',
marginTop: 20,
marginBottom: 10
}
})
export const BusinessInformation = (props : BusinessInformationParams) => {
const BusinessInformationProps = {
...props,
UIComponent: BusinessInformationUI
}
return
}