Commit e9ee053a authored by pramod.nichelabs's avatar pramod.nichelabs

auction list page api added

parent 1900eeee
...@@ -4,9 +4,17 @@ import themeColors from '../assets/colors'; ...@@ -4,9 +4,17 @@ import themeColors from '../assets/colors';
export const AppStakeItem = (props) => { export const AppStakeItem = (props) => {
const [bid, setBid] = useState({}); const [bid, setBid] = useState({});
const initialValues = {
id : "1",
name : "Saman",
bidprice : 908
}
useEffect(() => { useEffect(() => {
if (props.bid === undefined) {
setBid(initialValues)
} else {
setBid(props.bid) setBid(props.bid)
}
}, []) }, [])
return( return(
<View style={styles.stake}> <View style={styles.stake}>
......
...@@ -17,7 +17,7 @@ export const AppAuctionItem = props => { ...@@ -17,7 +17,7 @@ export const AppAuctionItem = props => {
<View> <View>
{props.delete ? ( {props.delete ? (
<View style={styles.container}> <View style={styles.container}>
<TouchableOpacity onPress={props.onSelect} style={styles.button}> <TouchableOpacity onPress={props.onPress} style={styles.button}>
<Text style={styles.label}>{props.label}</Text> <Text style={styles.label}>{props.label}</Text>
<AppCountDownTimer secs={secs}/> <AppCountDownTimer secs={secs}/>
</TouchableOpacity> </TouchableOpacity>
......
...@@ -6,16 +6,31 @@ import themeColors from '../assets/colors'; ...@@ -6,16 +6,31 @@ import themeColors from '../assets/colors';
import { AuctionBottomTab } from '../Navigations/AuctionBottomTab'; import { AuctionBottomTab } from '../Navigations/AuctionBottomTab';
const AuctionListScreen = ({navigation}) => { const AuctionListScreen = ({navigation}) => {
const [auctions, setAuctions] = useState([]);
useEffect(() => {
axios.get("http://127.0.0.1:8085/auctions")
.then( async function (response) {
setAuctions(response.data);
})
.catch(function (error) {
console.log(error);
})
}, [])
return ( return (
<View style={styles.container}> <View style={styles.container}>
<AppContainer> <AppContainer>
<Text style={styles.auctionHeading}>Auctions List</Text> <Text style={styles.auctionHeading}>Auctions</Text>
<ScrollView> <ScrollView>
<View> <View>
<AppAuctionItem label='Auction Item 1' onPress = {() => navigation.navigate("SignUp")}/> {auctions.map((auction) => {
<AppAuctionItem label='Auction Item 2'/> return(
<AppAuctionItem label='Auction Item 3'/> <AppAuctionItem label={auction.name} expire={auction.expire_date} onPress = {() =>
<AppAuctionItem label='Auction Item 4'/> navigation.navigate("AuctionDetailScreen", {
auctionObject: auction})
}/>
)
})}
</View> </View>
</ScrollView> </ScrollView>
</AppContainer> </AppContainer>
......
import React from 'react'; import React, {useState, useEffect} from 'react';
import axios from 'axios';
import {View, StyleSheet, Text, ScrollView, TouchableOpacity} from 'react-native'; import {View, StyleSheet, Text, ScrollView, TouchableOpacity} from 'react-native';
import { AppAuctionItem } from '../components/auction_item.component'; import { AppAuctionItem } from '../components/auction_item.component';
import { AppContainer } from '../container/container'; import { AppContainer } from '../container/container';
...@@ -7,6 +8,17 @@ import { AuctionBottomTab } from '../Navigations/AuctionBottomTab'; ...@@ -7,6 +8,17 @@ import { AuctionBottomTab } from '../Navigations/AuctionBottomTab';
import { MaterialIcons } from '@expo/vector-icons'; import { MaterialIcons } from '@expo/vector-icons';
const UserAuctionListScreen = ({navigation}) => { const UserAuctionListScreen = ({navigation}) => {
const [auctions, setAuctions] = useState([]);
useEffect(() => {
axios.get("http://127.0.0.1:8085/auctions")
.then( async function (response) {
setAuctions(response.data);
})
.catch(function (error) {
console.log(error);
})
}, [])
return ( return (
<View style={styles.container}> <View style={styles.container}>
<AppContainer> <AppContainer>
...@@ -17,10 +29,15 @@ const UserAuctionListScreen = ({navigation}) => { ...@@ -17,10 +29,15 @@ const UserAuctionListScreen = ({navigation}) => {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<ScrollView> <ScrollView>
<AppAuctionItem label='Auction Item 178' delete onSelect = {() => navigation.navigate("AuctionDetailScreen")}/> {auctions.map((auction) => {
<AppAuctionItem label='Auction Item 2' delete/> return(
<AppAuctionItem label='Auction Item 3' delete/> <AppAuctionItem delete label={auction.name} expire={auction.expire_date}
<AppAuctionItem label='Auction Item 4' delete/> onPress={() =>
navigation.navigate("AuctionDetailScreen", {
auctionObject: auction})
}/>
)
})}
</ScrollView> </ScrollView>
</AppContainer> </AppContainer>
<AuctionBottomTab/> <AuctionBottomTab/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment