Edit Product Screen in React native expo | Web Scripts | Crax

Welcome To Crax.Pro Forum!

Check our new Marketplace at Crax.Shop

   Login! SignUp Now!
  • We are in solidarity with our brothers and sisters in Palestine. Free Palestine. To learn more visit this Page

  • Crax.Pro domain has been taken down!

    Alternatives: Craxpro.io | Craxpro.com

Edit Product Screen in React native expo

Edit Product Screen in React native expo

LV
0
 

tempcp001

Member
Joined
Jan 7, 2024
Threads
12
Likes
0
Awards
2
Credits
1,203©
Cash
0$
import React, { useState } from 'react';
import { FlatList, View } from 'react-native';
import { Searchbar } from 'react-native-paper';
import RestaurantCard from './card';
import { useNavigation } from '@react-navigation/native';
const ProductsScreen = () => {
const [searchQuery, setSearchQuery] = useState('');
const navigation = useNavigation();
const restaurants = [
// Dummy data. Replace this with actual data.
{ id: 1, name: 'Food Truck 1', title: 'Title 1', status: 'Open', zipcode: '12345', type: 'Italian', createdAt: new Date() },
{ id: 2, name: 'Food Truck 2', title: 'Title 2', status: 'Closed', zipcode: '67890', type: 'Mexican', createdAt: new Date() },
//...
];
const onChangeSearch = query => setSearchQuery(query);
const handleEdit = (restaurantId) => {
// Handle edit action
navigation.navigate('EditProductScreen');
};
const handleDelete = (restaurantId) => {
// Handle delete action
console.log(`Deleting restaurant with id ${restaurantId}`);
};
const viewReviews = (restaurantId) => {
// Handle delete action
navigation.navigate('ReviewsScreen');
};
const filteredRestaurants = restaurants.filter(restaurant => {
const { name, title, status, zipcode, type } = restaurant;
const lowerCaseQuery = searchQuery.toLowerCase();
return (
name.toLowerCase().includes(lowerCaseQuery) ||
title.toLowerCase().includes(lowerCaseQuery) ||
status.toLowerCase().includes(lowerCaseQuery) ||
zipcode.toLowerCase().includes(lowerCaseQuery) ||
type.toLowerCase().includes(lowerCaseQuery)
);
});
return (
<View>
<View style={{ margin: 10, marginBottom: 0 }}>
<Searchbar
placeholder="Search"
onChangeText={onChangeSearch}
value={searchQuery}
theme={{
roundness: 20,
colors: {
primary: '#000',
text: '#000',
placeholder: '#000',
background: '#fff',
},
}}
/>
</View>
<FlatList
data={filteredRestaurants}
keyExtractor={item => item.id.toString()}
renderItem={({ item }) => (
<RestaurantCard restaurant={item} onEdit={handleEdit} onDelete={handleDelete} viewReviews={viewReviews} />
)}
contentContainerStyle={{ padding: 10 }}
/>
</View>
);
};
export default ProductsScreen;
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Top Bottom