farhantock
5 months ago
9 changed files with 0 additions and 354 deletions
@ -1,24 +0,0 @@
|
||||
import React from "react"; |
||||
import { Alert, CloseIcon, HStack, IconButton, Text, Toast, ToastDescription, ToastTitle, useToast, VStack } from "@gluestack-ui/themed"; |
||||
|
||||
const CustomToast = ({ |
||||
id, |
||||
status, |
||||
variant, |
||||
title, |
||||
description, |
||||
isClosable, |
||||
...rest |
||||
}) => { |
||||
const toast = useToast(); |
||||
return ( |
||||
<Toast nativeID={"toast-" + id} action={status ? status : "info"} variant={variant ? variant : "accent"}> |
||||
<VStack space="xs"> |
||||
{ title ? <ToastTitle>{title}</ToastTitle> : null } |
||||
{ description ? <ToastDescription>{description}</ToastDescription> : null } |
||||
</VStack> |
||||
</Toast> |
||||
) |
||||
} |
||||
|
||||
export default CustomToast; |
@ -1,15 +0,0 @@
|
||||
import React from "react"; |
||||
import { View } from "react-native"; |
||||
|
||||
const HorizontalLine = ({width, borderStyle}) => { |
||||
return <View style={{ |
||||
borderBottomWidth: 1, |
||||
minWidth: width ? width : 25, |
||||
flex: 1, |
||||
alignSelf: 'center', |
||||
borderColor: '#d9d8d7', |
||||
borderStyle: borderStyle ? borderStyle : 'solid' |
||||
}}></View> |
||||
} |
||||
|
||||
export default HorizontalLine; |
@ -1,11 +0,0 @@
|
||||
import React from "react" |
||||
import { Box, Text } from "@gluestack-ui/themed" |
||||
import { strings } from "../utils/i18n" |
||||
|
||||
export const NoDataContent = () => { |
||||
return ( |
||||
<Box flex={1} alignItems='center' my="$1/2"> |
||||
<Text color="red">{strings('global.noData')}</Text> |
||||
</Box> |
||||
) |
||||
} |
@ -1,144 +0,0 @@
|
||||
import { Box, HStack, Heading, Text } from '@gluestack-ui/themed' |
||||
import { VStack } from '@gluestack-ui/themed' |
||||
import React from 'react' |
||||
import { strings } from '../utils/i18n' |
||||
import VerticalLine from './VerticalLine' |
||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; |
||||
import { colorStatusDecider, dropPointLocationRenderer } from '../utils/general' |
||||
import { Image, ScrollView } from 'react-native' |
||||
import { TouchableOpacity } from 'react-native-gesture-handler' |
||||
import { store } from '../appredux/store' |
||||
import { setSelectedHistoryPicture, setSelectedHistoryPictures, setShowHistoryPicture } from '../appredux/actions' |
||||
|
||||
export const RenderDeliveryOrder = ({data}) => { |
||||
if (data && data.length > 0) { |
||||
return data.map((item, idx) => { |
||||
return ( |
||||
<VStack key={idx}> |
||||
<Text _dark={{ color: "$textLight200" }} fontSize="$md"> |
||||
{strings('label.dropPointLocations')} |
||||
</Text> |
||||
|
||||
<RenderDropPoint data={item.drop_point} /> |
||||
</VStack> |
||||
) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
export const PointConnector = () => { |
||||
return ( |
||||
<HStack py={4}> |
||||
<VStack w='20%' alignItems='center' alignSelf='center'> |
||||
<VerticalLine /> |
||||
</VStack> |
||||
<VStack w='80%'></VStack> |
||||
</HStack> |
||||
) |
||||
} |
||||
|
||||
export const RenderDropPoint = ({data}) => { |
||||
if (data && data.length > 0) { |
||||
return data.map((item, idx) => { |
||||
return ( |
||||
<VStack key={idx}> |
||||
<HStack py={4}> |
||||
<VStack w='20%' alignItems='center' alignSelf='center'> |
||||
<MaterialCommunityIcons |
||||
name="map-marker" |
||||
color={colorStatusDecider(item)} |
||||
size={30} |
||||
/> |
||||
</VStack> |
||||
<VStack w='80%'> |
||||
<Heading
|
||||
style={{color: colorStatusDecider(item)}} |
||||
size="sm"> |
||||
{dropPointLocationRenderer(item, 'name')} |
||||
</Heading> |
||||
<Text |
||||
style={{color: colorStatusDecider(item)}} |
||||
fontSize="$sm"> |
||||
{dropPointLocationRenderer(item, 'address')} |
||||
</Text> |
||||
|
||||
{item.status === 'completed' || item.status === 'cancel' ? |
||||
<RenderDropPointPictures data={item.attachments} />
|
||||
: null |
||||
} |
||||
|
||||
{item.status === 'completed' || item.status === 'cancel' ? |
||||
<RenderDropPointSignature data={item.signatures} />
|
||||
: null |
||||
} |
||||
|
||||
{item.status === 'completed' || item.status === 'cancel' ? |
||||
<Box mt={5}> |
||||
<Text bold>{strings('global.notes')}:</Text> |
||||
<Text>{item.driver_notes && item.driver_notes !== '' ? item.driver_notes : '-'}</Text> |
||||
</Box> |
||||
: null |
||||
} |
||||
|
||||
</VStack> |
||||
</HStack> |
||||
{ idx !== data.length - 1 ? <PointConnector /> : null} |
||||
</VStack> |
||||
) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
export const RenderDropPointPictures = ({data}) => { |
||||
return ( |
||||
<VStack mt={10}> |
||||
<Box> |
||||
<Text bold>{strings('history.dropPointPictures')}</Text> |
||||
</Box> |
||||
<ScrollView horizontal={true} showsHorizontalScrollIndicator={false}> |
||||
{ data && data.length > 0 ? data.map((item, idx) => ( |
||||
<TouchableOpacity key={idx} onPress={() => { |
||||
store.dispatch(setSelectedHistoryPicture(item)) |
||||
store.dispatch(setShowHistoryPicture(true)) |
||||
}}> |
||||
<Box pr={5}> |
||||
<Image
|
||||
idx={idx} |
||||
source={{uri: item}} |
||||
height={100} |
||||
width={120} |
||||
/> |
||||
</Box> |
||||
</TouchableOpacity> |
||||
)) : <Text>-</Text> } |
||||
</ScrollView> |
||||
</VStack> |
||||
) |
||||
} |
||||
|
||||
export const RenderDropPointSignature = ({data}) => { |
||||
return ( |
||||
<VStack mt={10}> |
||||
<Box> |
||||
<Text bold>{strings('history.signaturePicture')}</Text> |
||||
</Box> |
||||
<ScrollView horizontal={true} showsHorizontalScrollIndicator={false}> |
||||
{ data && data.length > 0 ? data.map((item, idx) => ( |
||||
<TouchableOpacity key={idx} onPress={() => { |
||||
store.dispatch(setSelectedHistoryPicture(item)) |
||||
store.dispatch(setShowHistoryPicture(true)) |
||||
}}> |
||||
<Box pr={5}> |
||||
<Image
|
||||
idx={idx} |
||||
source={{uri: item}} |
||||
height={150} |
||||
width={120} |
||||
/> |
||||
</Box> |
||||
</TouchableOpacity> |
||||
)) : <Text>-</Text> } |
||||
</ScrollView> |
||||
</VStack> |
||||
) |
||||
} |
@ -1,13 +0,0 @@
|
||||
import React from "react"; |
||||
import { View } from "react-native"; |
||||
|
||||
const VerticalLine = ({height}) => { |
||||
return <View style={{ |
||||
borderWidth: 0.2, |
||||
minHeight: height ? height : 10, |
||||
borderColor: 'grey', |
||||
// borderStyle: 'dashed'
|
||||
}}></View> |
||||
} |
||||
|
||||
export default VerticalLine; |
@ -1,20 +0,0 @@
|
||||
|
||||
import { deleteRow, dropTable, insertTable, selectRow } from './index'; |
||||
|
||||
const TABLE_NAME = 'ospod_photo'; |
||||
|
||||
export const storePhoto = (user_id, drop_point_id, image_uri, image_blob, lat, lon) => { |
||||
insertTable(TABLE_NAME, [user_id, drop_point_id, image_uri, image_blob, lat, lon]) |
||||
} |
||||
|
||||
export const deletePhoto = (row_id, callback) => { |
||||
deleteRow(TABLE_NAME, row_id, (deleted) => callback(deleted)) |
||||
} |
||||
|
||||
export const selectAllPhoto = (callback) => { |
||||
selectRow(TABLE_NAME, null, (data) => callback(data)) |
||||
} |
||||
|
||||
export const dropTablePhoto = (callback) => { |
||||
dropTable(TABLE_NAME, (dropped) => callback(dropped)) |
||||
} |
@ -1,52 +0,0 @@
|
||||
import React from "react"; |
||||
import CustomToast from "../components/CustomToast"; |
||||
import { createContext, useContext, useRef } from "react"; |
||||
import Toast, { BaseToast, ErrorToast } from "react-native-toast-message"; |
||||
import { View, Text } from 'react-native' |
||||
|
||||
const renderTypeToast = (type) => { |
||||
let bgColor = 'muted.600' |
||||
if (type) { |
||||
if (type === 'success') { |
||||
bgColor = 'green.600'; |
||||
} |
||||
else if (type === 'error') { |
||||
bgColor = 'red.600'; |
||||
} |
||||
else if (type === 'warning') { |
||||
bgColor = 'yellow.600'; |
||||
} |
||||
} |
||||
return bgColor; |
||||
} |
||||
|
||||
export const toastr = { |
||||
show: (message, type, duration = 5000) => { |
||||
return ( |
||||
<CustomToast |
||||
// title="Something went wrong"
|
||||
description={message} |
||||
variant="accent" |
||||
isClosable={true} |
||||
status={type} |
||||
bg={renderTypeToast(type)} |
||||
/> |
||||
) |
||||
}, |
||||
}; |
||||
|
||||
|
||||
|
||||
export const toastConfig = { |
||||
success: ({ text1, props }) => ( |
||||
<View style={{ width: '80%', backgroundColor: 'green', borderRadius: 10, padding: 10, marginBottom: 35}}> |
||||
<Text style={{ color: '#ffffff', fontSize: 14 }}>{text1}</Text> |
||||
</View> |
||||
), |
||||
|
||||
error: ({ text1, props }) => ( |
||||
<View style={{ width: '80%', backgroundColor: 'red', borderRadius: 10, padding: 10, marginBottom: 35}}> |
||||
<Text style={{ color: '#ffffff', fontSize: 14 }}>{text1}</Text> |
||||
</View> |
||||
) |
||||
}; |
@ -1,37 +0,0 @@
|
||||
import { color_cancel, color_complete, color_on_progress, color_open } from "../config/Styles"; |
||||
|
||||
export const EMPTY_DATE = ["1900-01-01 00:00:00", null, ""]; |
||||
export const DATE_FORMAT = "D MMMM YYYY HH:mm"; |
||||
|
||||
export const dropPointLocationRenderer = (data, key) => { |
||||
let spatial_type = data.spatial_type; |
||||
let output = '-'; |
||||
let key_ = 'transitpoint_'+key; |
||||
if (spatial_type === 'pool') { |
||||
key_ = 'pool_'+key; |
||||
output = data?.join?.[key_]; |
||||
} |
||||
else if (spatial_type === 'transit_point') { |
||||
key_ = 'transitpoint_'+key; |
||||
output = data?.join?.[key_]; |
||||
} |
||||
else if (spatial_type === 'geofence') { |
||||
key_ = 'geofence_'+key; |
||||
output = data?.join?.[key_]; |
||||
} |
||||
|
||||
// validate to put -
|
||||
if (output == "") { |
||||
output = "-" |
||||
} |
||||
|
||||
return output; |
||||
} |
||||
|
||||
export const colorStatusDecider = (item) => { |
||||
if (!item) { |
||||
return null; |
||||
} |
||||
// return item.status === "open" || EMPTY_DATE.includes(item.in_time) ? color_open : item.status === "on-progress" ? color_on_progress : color_complete
|
||||
return item.status === "open" ? color_open : item.status === "on-progress" ? color_on_progress : item.status === "completed" ? color_complete : color_cancel; |
||||
} |
@ -1,38 +0,0 @@
|
||||
import { setSelectedDropPoint, setShipmentData } from "../appredux/actions"; |
||||
import { store } from "../appredux/store"; |
||||
import ApiShipment from "../services/api/shipment"; |
||||
|
||||
|
||||
export const getShipmentData = async () => { |
||||
const shipment = await ApiShipment.searchDetail('open,on-progress'); |
||||
if (shipment && shipment.status === true && shipment.data) { |
||||
if (shipment.data.length > 0) { |
||||
return shipment.data[0]; |
||||
} |
||||
else { |
||||
return null; |
||||
} |
||||
} |
||||
else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
|
||||
// this function is to update shipmentData and selectedDropPoint state in redux based on current selectedDropPoint
|
||||
// flow -> get API then update redux state
|
||||
export const updateShipmentState = (dp_item, callback) => { |
||||
let promiseSave = new Promise((resolve, reject) => { |
||||
let shipment = getShipmentData(); |
||||
resolve(shipment); |
||||
}) |
||||
promiseSave.then(val => { |
||||
let doIdx = val.delivery_order.findIndex(x => parseInt(x.id) === parseInt(dp_item.delivery_order)); |
||||
let dpIdx = val.delivery_order[doIdx].drop_point.findIndex(x => parseInt(x.id) === parseInt(dp_item.id)); |
||||
let updatedDp = val.delivery_order[doIdx].drop_point[dpIdx]; |
||||
store.dispatch(setShipmentData(val)); |
||||
store.dispatch(setSelectedDropPoint(null)); |
||||
store.dispatch(setSelectedDropPoint(updatedDp)) |
||||
callback(updatedDp) |
||||
}) |
||||
} |
Loading…
Reference in new issue