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
ba239065
Commit
ba239065
authored
May 24, 2021
by
Nguyễn Thị Thúy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format money
parent
e29604ca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
Functions.js
src/Config/Functions.js
+11
-0
ConvertUnit.js
src/Screens/Tool/ConvertUnit.js
+4
-7
No files found.
src/Config/Functions.js
View file @
ba239065
...
...
@@ -234,6 +234,17 @@ export const toPriceVnd = (str) => {
}
};
export
const
floatToPriceVnd
=
(
str
)
=>
{
if
(
str
)
{
let
stringPrice
=
str
.
toString
().
split
(
'.'
)
let
headStringPrice
=
`
${
stringPrice
[
0
].
replace
(
/
(\d)(?=(\d{3})
+
(?!\d))
/g
,
'$1,'
)}
`
return
stringPrice
.
length
===
1
?
headStringPrice
:
headStringPrice
.
concat
(
`.
${
stringPrice
[
1
]}
`
)
}
else
{
return
''
}
}
// cắt chuỗi dạng something...
export
const
ellipsis
=
(
str
=
''
,
max
=
30
)
=>
str
.
length
>
max
?
`
${
str
.
substring
(
0
,
max
)}
...`
:
str
;
...
...
src/Screens/Tool/ConvertUnit.js
View file @
ba239065
...
...
@@ -5,7 +5,7 @@ import HeaderBack from '../../components/Header/HeaderBack';
import
PickerItem
from
'../../components/Picker/PickerItem'
;
import
I18n
from
'../../helper/i18/i18n'
;
import
AppText
from
'../../components/AppText'
;
import
{
getFontXD
,
HEIGHTXD
,
toPriceVnd
,
WIDTHXD
}
from
'../../Config/Functions'
;
import
{
floatToPriceVnd
,
getFontXD
,
HEIGHTXD
,
toPriceVnd
,
WIDTHXD
}
from
'../../Config/Functions'
;
import
R
from
'../../assets/R'
;
import
{
getUnitList
}
from
'../../apis/Functions/Transaction'
;
import
{
showAlert
,
TYPE
}
from
'../../components/DropdownAlert'
;
...
...
@@ -71,16 +71,12 @@ const ConvertUnit = (props) => {
const
onChangeToUnit
=
(
value
,
item
)
=>
{
setToUnit
(
item
);
if
(
number
&&
number
!=
''
&&
parseFloat
(
number
)
>
0
)
{
let
result
=
parseFloat
(
number
)
*
item
.
rate
;
setResult
(
`
${
parseFloat
(
number
)}
${
fromUnit
.
name
}
=
${
result
}
${
item
.
name
}
`
);
}
};
const
calcultorResult
=
()
=>
{
if
(
number
&&
number
!=
''
&&
parseFloat
(
number
)
>
0
)
{
let
result
=
parseFloat
(
number
)
*
toUnit
.
rate
;
setResult
(
`
${
parseFloat
(
number
)}
${
fromUnit
.
name
}
=
${
result
}
${
toUnit
.
name
}
`
);
setResult
(
`
${
floatToPriceVnd
(
number
.
toString
())}
${
fromUnit
.
name
}
=
${
floatToPriceVnd
(
result
.
toString
())
}
${
toUnit
.
name
}
`
);
}
else
{
setResult
(
''
)
}
...
...
@@ -98,7 +94,7 @@ const ConvertUnit = (props) => {
keyboardType
=
{
'number-pad'
}
style
=
{
styles
.
wrapInput
}
maxLength
=
{
12
}
value
=
{
t
oPriceVnd
(
number
)}
value
=
{
floatT
oPriceVnd
(
number
)}
/
>
<
/View
>
<
/View
>
...
...
@@ -179,6 +175,7 @@ const styles = StyleSheet.create({
fontSize
:
getFontXD
(
42
),
borderRadius
:
5
,
paddingHorizontal
:
10
,
paddingVertical
:
0
,
shadowColor
:
'#000'
,
shadowOffset
:
{
width
:
0
,
...
...
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