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';
export const AppStakeItem = (props) => {
const [bid, setBid] = useState({});
const initialValues = {
id : "1",
name : "Saman",
bidprice : 908
}
useEffect(() => {
setBid(props.bid)
if (props.bid === undefined) {
setBid(initialValues)
} else {
setBid(props.bid)
}
}, [])
return(
<View style={styles.stake}>
......
......@@ -17,7 +17,7 @@ export const AppAuctionItem = props => {
<View>
{props.delete ? (
<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>
<AppCountDownTimer secs={secs}/>
</TouchableOpacity>
......
......@@ -6,16 +6,31 @@ import themeColors from '../assets/colors';
import { AuctionBottomTab } from '../Navigations/AuctionBottomTab';
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 (
<View style={styles.container}>
<AppContainer>
<Text style={styles.auctionHeading}>Auctions List</Text>
<Text style={styles.auctionHeading}>Auctions</Text>
<ScrollView>
<View>
<AppAuctionItem label='Auction Item 1' onPress = {() => navigation.navigate("SignUp")}/>
<AppAuctionItem label='Auction Item 2'/>
<AppAuctionItem label='Auction Item 3'/>
<AppAuctionItem label='Auction Item 4'/>
{auctions.map((auction) => {
return(
<AppAuctionItem label={auction.name} expire={auction.expire_date} onPress = {() =>
navigation.navigate("AuctionDetailScreen", {
auctionObject: auction})
}/>
)
})}
</View>
</ScrollView>
</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 { AppAuctionItem } from '../components/auction_item.component';
import { AppContainer } from '../container/container';
......@@ -7,6 +8,17 @@ import { AuctionBottomTab } from '../Navigations/AuctionBottomTab';
import { MaterialIcons } from '@expo/vector-icons';
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 (
<View style={styles.container}>
<AppContainer>
......@@ -17,10 +29,15 @@ const UserAuctionListScreen = ({navigation}) => {
</TouchableOpacity>
</View>
<ScrollView>
<AppAuctionItem label='Auction Item 178' delete onSelect = {() => navigation.navigate("AuctionDetailScreen")}/>
<AppAuctionItem label='Auction Item 2' delete/>
<AppAuctionItem label='Auction Item 3' delete/>
<AppAuctionItem label='Auction Item 4' delete/>
{auctions.map((auction) => {
return(
<AppAuctionItem delete label={auction.name} expire={auction.expire_date}
onPress={() =>
navigation.navigate("AuctionDetailScreen", {
auctionObject: auction})
}/>
)
})}
</ScrollView>
</AppContainer>
<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