Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InvestCustomer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
InvestCustomer
Commits
bc0c8dc0
Commit
bc0c8dc0
authored
May 18, 2021
by
Giang Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connect api
parent
236c9540
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
63 deletions
+42
-63
ExchangeRate.js
src/Screens/Tool/ExchangeRate.js
+35
-63
Transaction.js
src/apis/Functions/Transaction.js
+5
-0
url.js
src/apis/url.js
+2
-0
No files found.
src/Screens/Tool/ExchangeRate.js
View file @
bc0c8dc0
...
...
@@ -16,78 +16,42 @@ import TextField from '../../components/Input/TextField';
import
{
getFontXD
,
HEIGHTXD
,
toPriceVnd
,
WIDTHXD
}
from
'../../Config/Functions'
;
import
R
from
'../../assets/R'
;
import
{
showAlert
,
TYPE
}
from
'../../components/DropdownAlert'
;
import
{
getTransactionListByCategory
}
from
'../../apis/Functions/Transaction'
;
const
DATA
=
[
{
id
:
1
,
name
:
'Đậu tương'
,
value
:
0.36744
,
},
{
id
:
2
,
name
:
'Khô đậu tương'
,
value
:
1.1023
,
},
{
id
:
3
,
name
:
'Dầu đậu tương'
,
value
:
22.0462
,
},
{
id
:
4
,
name
:
'Ngô'
,
value
:
0.39368
,
},
{
id
:
5
,
name
:
'Lúa mỳ'
,
value
:
0.36744
,
},
{
id
:
6
,
name
:
'Cà phê arabica'
,
value
:
22.0462
,
},
{
id
:
7
,
name
:
'Cà phê Robusta'
,
value
:
1
,
},
{
id
:
8
,
name
:
'Ca cao'
,
value
:
1
,
},
{
id
:
9
,
name
:
'Bông'
,
value
:
22.0462
,
},
{
id
:
10
,
name
:
'Đường'
,
value
:
22.0462
,
},
{
id
:
11
,
name
:
'Cao su'
,
value
:
9.4
,
},
];
import
{
getListExchangeRate
}
from
'../../apis/Functions/Transaction'
;
import
{
showLoading
,
hideLoading
}
from
'../../actions/loadingAction'
;
import
{
connect
}
from
'react-redux'
;
const
ExchangeRate
=
(
props
)
=>
{
const
[
product
,
setProduct
]
=
useState
();
const
[
priceExchange
,
setPriceExchange
]
=
useState
();
const
[
usdTan
,
setUsdTan
]
=
useState
();
const
[
dataProduct
,
setDataProduct
]
=
useState
([]);
useEffect
(()
=>
{
getProductData
();
},
[]);
const
getProductData
=
async
()
=>
{
props
.
showLoading
();
const
res
=
await
getListExchangeRate
({
platform
:
Platform
.
OS
,
page_size
:
1000
,
page_index
:
1
,
});
props
.
hideLoading
();
if
(
res
.
status
==
200
&&
res
.
data
.
code
==
200
)
{
setDataProduct
(
res
.
data
.
data
);
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
,
I18n
.
t
(
'Can_not_get_data'
)));
}
};
useEffect
(()
=>
{
caculator
();
},
[
product
,
priceExchange
]);
const
caculator
=
()
=>
{
if
(
product
&&
priceExchange
)
{
const
total
=
priceExchange
*
product
.
valu
e
;
const
total
=
priceExchange
*
product
.
exchange_rat
e
;
setUsdTan
(
total
+
''
);
}
else
if
(
!
priceExchange
)
setUsdTan
(
''
);
};
...
...
@@ -99,7 +63,7 @@ const ExchangeRate = (props) => {
<
AppText
style
=
{
styles
.
txtTitle
}
i18nKey
=
{
'Product'
}
/
>
<
PickerItem
width
=
{
width
-
20
}
data
=
{
DATA
}
data
=
{
dataProduct
}
onValueChange
=
{(
value
,
items
)
=>
{
setProduct
(
items
);
}}
...
...
@@ -194,4 +158,12 @@ const styles = StyleSheet.create({
marginTop
:
10
,
},
});
export
default
ExchangeRate
;
const
mapStateToProps
=
(
state
)
=>
{
return
{
user
:
state
.
userReducer
,
};
};
export
default
connect
(
mapStateToProps
,
{
showLoading
,
hideLoading
})(
ExchangeRate
,
);
src/apis/Functions/Transaction.js
View file @
bc0c8dc0
...
...
@@ -21,3 +21,8 @@ export const getProfitLost = async (body) =>
PostData
(
url
.
urlProfitLost
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
export
const
getListExchangeRate
=
async
(
body
)
=>
GetData
(
url
.
urlGetListExchangeRate
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
src/apis/url.js
View file @
bc0c8dc0
...
...
@@ -55,4 +55,6 @@ export default {
urlSendRequest
:
root
+
'api/v1/customers/send-request'
,
urlProfitLost
:
root
+
'api/v1/customers/calculate-profit'
,
urlGetListExchangeRate
:
root
+
'api/v1/customers/get-list-exchange-rate'
,
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment