Commit 2e4028a3 authored by Neosoulink's avatar Neosoulink
Browse files

feat: add method to navigate to product details

parent d2b67e99
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ import { Avatar, Title, Text, Button } from 'react-native-paper';
import Ionicons from '@expo/vector-icons/Ionicons';

// TYPES
import type { ProductItemType } from './index';
import type { PropsItemInterface } from './index';

// STYLES
import {
@@ -15,12 +15,7 @@ import {
	CONSTANT_COLOR as CC,
} from '../../../assets/ts/styles';

export interface Props {
	data: ProductItemType['data'];
	onPressProfile: () => any;
}

const ProductItemList: React.FC<Props> = (props) => {
const ProductItemList: React.FC<PropsItemInterface> = (props) => {
	// LOCAL STYLES
	const STYLES = StyleSheet.create({
		container: {
@@ -137,7 +132,8 @@ const ProductItemList: React.FC<Props> = (props) => {
					labelStyle={{
						...GS.FF_NunitoSemiBold,
						color: CC.light,
					}}>
					}}
					onPress={props.onPressDetails}>
					Details
				</Button>
			</View>
+4 −9
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ import { Avatar, Title, Text, Button } from 'react-native-paper';
import Ionicons from '@expo/vector-icons/Ionicons';

// TYPES
import type { ProductItemType } from '.';
import type { PropsItemInterface } from '.';

// STYLES
import {
@@ -15,13 +15,7 @@ import {
	CONSTANT_COLOR as CC,
} from '../../../assets/ts/styles';

// LOCAL TYPES
export interface Props {
	data: ProductItemType['data'];
	onPressProfile: () => any;
}

const ProductItemSlide: React.FC<Props> = (props) => {
const ProductItemSlide: React.FC<PropsItemInterface> = (props) => {
	// DATA
	const AVATAR_WAREHOUSE_SIZE = CS.FONT_SIZE_XLG * 2.5;

@@ -198,7 +192,8 @@ const ProductItemSlide: React.FC<Props> = (props) => {
					labelStyle={{
						...GS.FF_NunitoSemiBold,
						color: CC.light,
					}}>
					}}
					onPress={props.onPressDetails}>
					Details
				</Button>
			</View>
+27 −9
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ import ProductItemVertical from './List';
import ProductItemHorizontal from './Slide';

// LOCAL TYPES
export interface ProductItemType {
export interface ProductItemInterface {
	data: {
		warehouseId: string;
		warehouseLogo?: string;
@@ -26,17 +26,22 @@ export interface ProductItemType {
	type: ENV['PRODUCTS_VIEW_TYPE'];
}

const ProductItem: React.FC<ProductItemType> = (props) => {
export interface PropsItemInterface {
	data: ProductItemInterface['data'];
	onPressProfile: () => any;
	onPressDetails: () => any;
}

const ProductItem: React.FC<ProductItemInterface> = (props) => {
	// NAVIGATION
	const NAVIGATION = useNavigation();

	// DATA
	// FUNCTIONS
	const onPressProfile = () => {
		const ROUTE_WAREHOUSE_ID = {
			warehouseId: props?.data.warehouseId,
		};

	// FUNCTIONS
	const onPressProfile = () => {
		if (!isEmpty(ROUTE_WAREHOUSE_ID.warehouseId)) {
			NAVIGATION.navigate(
				'DRAWER/IN_STORE' as never,
@@ -45,17 +50,30 @@ const ProductItem: React.FC<ProductItemType> = (props) => {
		}
	};

	const onPressDetails = () => {
		const ROUTE_PRODUCT_ID = {
			productId: props?.data.productId,
		};

		if (!isEmpty(ROUTE_PRODUCT_ID.productId)) {
			NAVIGATION.navigate(
				'DRAWER/PRODUCT_DETAILS' as never,
				ROUTE_PRODUCT_ID as never,
			);
		}
	};

	switch (props.type) {
		case 'list':
			return (
				<ProductItemVertical
					{...{ data: props.data, onPressProfile }}
					{...{ data: props.data, onPressProfile, onPressDetails }}
				/>
			);
		case 'slides':
			return (
				<ProductItemHorizontal
					{...{ data: props.data, onPressProfile }}
					{...{ data: props.data, onPressProfile, onPressDetails }}
				/>
			);
		default: