Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ReactNativeBase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Danh Khanh
ReactNativeBase
Commits
c3342b58
Commit
c3342b58
authored
Jul 06, 2021
by
Nguyen Danh Khanh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixUIinvntoryDone
parent
d0d199fe
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
64 additions
and
43 deletions
+64
-43
src/api/listProduct.ts
src/api/listProduct.ts
+1
-2
src/components/ItemProduct/index.style.ts
src/components/ItemProduct/index.style.ts
+17
-15
src/components/ItemProduct/index.tsx
src/components/ItemProduct/index.tsx
+14
-12
src/redux/reducers/auth.ts
src/redux/reducers/auth.ts
+1
-1
src/redux/reducers/index.ts
src/redux/reducers/index.ts
+4
-0
src/redux/reducers/product.ts
src/redux/reducers/product.ts
+3
-3
src/redux/sagas/productSaga.ts
src/redux/sagas/productSaga.ts
+1
-1
src/screens/HomeCreateBill/index.tsx
src/screens/HomeCreateBill/index.tsx
+6
-6
src/screens/HomeProductCreate/index.tsx
src/screens/HomeProductCreate/index.tsx
+17
-3
No files found.
src/api/listProduct.ts
View file @
c3342b58
import
axios
from
'
axios
'
import
axios
from
'
axios
'
import
config
from
'
../configs
'
import
config
from
'
../configs
'
import
{
store
}
from
'
../redux/store
'
import
{
store
}
from
'
../redux/store
'
...
@@ -16,7 +15,7 @@ export function getListProducts() {
...
@@ -16,7 +15,7 @@ export function getListProducts() {
}
}
const
header
=
{
const
header
=
{
headers
:
{
headers
:
{
'
Authorization
'
:
'
eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIzNjQ5LTAiLCJpYXQiOjE2MjUzOTI5MzIsImV4cCI6MTYyNTQ3OTMzMn0.l_z2ABgvD51hDJmI-mOGM9gOpBTlhyp3UPUNDTbsdWAcZ0KTzeLmJXhV81HdH2S3_mtmM_bGlHCnPi_wHueBkw
'
'
Authorization
'
:
token
}
}
}
}
const
baseURL
=
config
.
axiosConfig
().
baseURL
const
baseURL
=
config
.
axiosConfig
().
baseURL
...
...
src/components/ItemProduct/index.style.ts
View file @
c3342b58
...
@@ -3,24 +3,26 @@ import { StyleSheet } from "react-native";
...
@@ -3,24 +3,26 @@ import { StyleSheet } from "react-native";
const
styles
=
StyleSheet
.
create
({
const
styles
=
StyleSheet
.
create
({
inputLogin
:
{
container
:
{
flexDirection
:
"
row
"
,
flexDirection
:
'
row
'
,
height
:
40
,
padding
:
10
,
alignItems
:
"
center
"
,
borderBottomColor
:
'
#FFFFFF
'
,
borderBottomWidth
:
0.5
,
},
},
inputText
:
{
image
:
{
paddingLeft
:
5
,
width
:
60
,
paddingBottom
:
8
,
height
:
60
,
width
:
'
100%
'
,
},
},
validateText
:
{
infoContainer
:
{
color
:
'
red
'
,
marginLeft
:
10
,
fontSize
:
11
,
justifyContent
:
'
space-between
'
,
marginLeft
:
0
,
padding
:
5
,
alignItems
:
"
center
"
,
},
},
textName
:
{
fontSize
:
16
,
fontWeight
:
'
bold
'
},
textInfo
:
{
fontSize
:
16
,
}
});
});
export
default
styles
;
export
default
styles
;
\ No newline at end of file
src/components/ItemProduct/index.tsx
View file @
c3342b58
...
@@ -4,22 +4,24 @@ import { View, Text, Image, TextInput } from 'react-native';
...
@@ -4,22 +4,24 @@ import { View, Text, Image, TextInput } from 'react-native';
import
styles
from
'
./index.style
'
import
styles
from
'
./index.style
'
type
Props
=
{
type
Props
=
{
drg_drug_cd
:
string
,
drg_drug_name
:
string
,
lot
:
string
,
quantity
:
number
,
exp_date
:
string
image_url
:
string
,
drg_drug_cd
:
string
,
drg_drug_name
:
string
,
lot
:
string
,
quantity
:
number
,
exp_date
:
string
}
}
const
ItemProduct
=
(
props
:
Props
)
=>
{
const
ItemProduct
=
(
props
:
Props
)
=>
{
return
(
return
(
<
View
style=
{
styles
.
container
}
>
<
View
>
<
Image
style=
{
styles
.
image
}
source=
{
{
uri
:
props
.
image_url
}
}
/>
<
Text
>
<
View
style=
{
styles
.
infoContainer
}
>
<
Text
style=
{
styles
.
textName
}
>
{
`${props.drg_drug_cd} - ${props.drg_drug_name}`
}
{
`${props.drg_drug_cd} - ${props.drg_drug_name}`
}
</
Text
>
</
Text
>
<
Text
>
<
Text
style=
{
styles
.
textInfo
}
>
{
`Lô: ${props.lot} - Số lượng: ${props.quantity} - HSD: ${props.exp_date}`
}
{
`Lô: ${props.lot} - Số lượng: ${props.quantity} - HSD: ${props.exp_date}`
}
</
Text
>
</
Text
>
</
View
>
</
View
>
);
</
View
>
};
)
}
export
default
ItemProduct
;
export
default
ItemProduct
src/redux/reducers/auth.ts
View file @
c3342b58
...
@@ -22,7 +22,7 @@ const initialState : InitStateAuth = {
...
@@ -22,7 +22,7 @@ const initialState : InitStateAuth = {
function
productReducer
(
state
=
initialState
,
action
:
ActionType
)
{
function
productReducer
(
state
=
initialState
,
action
:
ActionType
)
{
const
payload
=
action
.
payload
const
payload
=
action
.
payload
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
case
'
LOGIN_SUCCESS
'
:
case
Types
.
LOGIN_SUCCESS
:
return
{
return
{
...
state
,
...
state
,
auth
:
payload
,
auth
:
payload
,
...
...
src/redux/reducers/index.ts
View file @
c3342b58
...
@@ -5,16 +5,20 @@ import auth, { InitStateAuth } from "./auth"
...
@@ -5,16 +5,20 @@ import auth, { InitStateAuth } from "./auth"
import
invoice
,
{
InitStateInvoice
}
from
'
./invoice
'
import
invoice
,
{
InitStateInvoice
}
from
'
./invoice
'
import
cart
from
'
./cart
'
import
cart
from
'
./cart
'
import
{
Cart
}
from
"
../../model/cart
"
;
import
{
Cart
}
from
"
../../model/cart
"
;
import
product
,
{
InitStateProduct
}
from
"
./product
"
;
export
type
RootState
=
{
export
type
RootState
=
{
auth
:
InitStateAuth
,
auth
:
InitStateAuth
,
invoice
:
InitStateInvoice
,
invoice
:
InitStateInvoice
,
cart
:
Cart
,
product
:
InitStateProduct
}
}
const
rootReducer
=
combineReducers
({
const
rootReducer
=
combineReducers
({
auth
,
auth
,
invoice
,
invoice
,
cart
,
cart
,
product
,
});
});
export
default
rootReducer
;
export
default
rootReducer
;
\ No newline at end of file
src/redux/reducers/product.ts
View file @
c3342b58
...
@@ -5,7 +5,7 @@ import Types from '../types'
...
@@ -5,7 +5,7 @@ import Types from '../types'
type
InitStateProduct
=
{
export
type
InitStateProduct
=
{
page
:
number
,
page
:
number
,
size
:
number
,
size
:
number
,
...
@@ -55,7 +55,7 @@ const defaultData = {
...
@@ -55,7 +55,7 @@ const defaultData = {
updated_user
:
''
,
updated_user
:
''
,
vat_percent
:
0
,
vat_percent
:
0
,
unit
:
[
defaultUnit
]
unit
:
[]
}
}
...
@@ -65,7 +65,7 @@ const initState: InitStateProduct = {
...
@@ -65,7 +65,7 @@ const initState: InitStateProduct = {
total_elements
:
0
,
total_elements
:
0
,
total_pages
:
1
,
total_pages
:
1
,
last
:
true
,
last
:
true
,
data
:
[
defaultData
]
data
:
[]
}
}
function
invoiceReducer
(
state
:
InitStateProduct
=
initState
,
action
:
AnyAction
)
{
function
invoiceReducer
(
state
:
InitStateProduct
=
initState
,
action
:
AnyAction
)
{
...
...
src/redux/sagas/productSaga.ts
View file @
c3342b58
...
@@ -9,7 +9,7 @@ function* fetchDataSaga(action:AnyAction) {
...
@@ -9,7 +9,7 @@ function* fetchDataSaga(action:AnyAction) {
console
.
log
(
action
)
console
.
log
(
action
)
try
{
try
{
const
data
:
any
=
yield
call
(
getListProducts
)
const
data
=
yield
call
(
getListProducts
)
console
.
log
(
'
SAGA:
'
,
data
.
data
)
//response: object chua data
console
.
log
(
'
SAGA:
'
,
data
.
data
)
//response: object chua data
yield
put
({
type
:
Types
.
ADD_PRODUCT_FROM_API
,
payload
:
data
.
data
})
yield
put
({
type
:
Types
.
ADD_PRODUCT_FROM_API
,
payload
:
data
.
data
})
}
}
...
...
src/screens/HomeCreateBill/index.tsx
View file @
c3342b58
...
@@ -60,12 +60,12 @@ const App = () => {
...
@@ -60,12 +60,12 @@ const App = () => {
</
TouchableOpacity
>
</
TouchableOpacity
>
)
)
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
const
products
=
useSelector
((
state
:
RootState
)
=>
state
.
product
.
data
)
//
const products = useSelector((state: RootState) => state.product.data)
console
.
log
(
'
///////////////////////////////////////////////////////////////////////////////
\n
'
,
products
)
//
console.log('///////////////////////////////////////////////////////////////////////////////\n', products)
const
[
product
,
setProduct
]
=
useState
(
products
)
//
const [product, setProduct] = useState(products)
useEffect
(()
=>
{
//
useEffect(() => {
setProduct
(
products
);
//
setProduct(products);
},
[
products
]);
//
}, [products]);
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
const
cartProducts
=
useSelector
((
state
:
RootState
)
=>
state
.
cart
.
products
)
const
cartProducts
=
useSelector
((
state
:
RootState
)
=>
state
.
cart
.
products
)
console
.
log
(
'
CART:
'
,
cartProducts
)
console
.
log
(
'
CART:
'
,
cartProducts
)
...
...
src/screens/HomeProductCreate/index.tsx
View file @
c3342b58
...
@@ -19,11 +19,12 @@ import ItemProduct from '../../components/ItemProduct';
...
@@ -19,11 +19,12 @@ import ItemProduct from '../../components/ItemProduct';
import
{
addProductToCart
}
from
'
../../redux/actions/cart
'
;
import
{
addProductToCart
}
from
'
../../redux/actions/cart
'
;
import
{
Cart
,
Product
}
from
"
../../model/cart
"
;
import
{
Cart
,
Product
}
from
"
../../model/cart
"
;
import
{
Data
}
from
'
../../model/product
'
;
import
{
Data
}
from
'
../../model/product
'
;
import
{
RootState
}
from
'
../../redux/reducers
'
;
const
App
=
()
=>
{
const
App
=
()
=>
{
//data product-------------------------------------------------------
//data product-------------------------------------------------------
const
products
=
useSelector
(
state
=>
state
.
product
.
data
)
const
products
=
useSelector
(
(
state
:
RootState
)
=>
state
.
product
.
data
)
console
.
log
(
'
Product:
'
,
products
)
console
.
log
(
'
Product:
'
,
products
)
//-------------------------------------------------------------------
//-------------------------------------------------------------------
const
_renderHeaderLeft
=
()
=>
{
const
_renderHeaderLeft
=
()
=>
{
...
@@ -51,12 +52,24 @@ const App = () => {
...
@@ -51,12 +52,24 @@ const App = () => {
/>
/>
)
)
const
ItemSeparatorView
=
()
=>
{
return
(
// Flat List Item Separator ______________________________________________
<
View
style=
{
{
height
:
1
,
width
:
'
100%
'
,
backgroundColor
:
'
#C8C8C8
'
,
}
}
/>
);
};
const
_renderListProduct
=
(
product
:
Data
)
=>
{
const
_renderListProduct
=
(
product
:
Data
)
=>
{
const
product1
=
product
return
(
return
(
<
TouchableOpacity
onPress=
{
()
=>
{
addToCart
(
product
)
}
}
>
<
TouchableOpacity
onPress=
{
()
=>
{
addToCart
(
product
)
}
}
>
<
ItemProduct
<
ItemProduct
image_url=
{
product
.
image_url
}
drg_drug_cd=
{
product
.
drg_drug_cd
}
drg_drug_cd=
{
product
.
drg_drug_cd
}
drg_drug_name=
{
product
.
drg_drug_name
}
drg_drug_name=
{
product
.
drg_drug_name
}
lot=
{
product
.
lot
}
lot=
{
product
.
lot
}
...
@@ -114,9 +127,10 @@ const App = () => {
...
@@ -114,9 +127,10 @@ const App = () => {
<
View
>
<
View
>
<
FlatList
<
FlatList
data=
{
products
}
data=
{
products
}
ItemSeparatorComponent=
{
ItemSeparatorView
}
renderItem=
{
({
item
})
=>
_renderListProduct
(
item
)
}
renderItem=
{
({
item
})
=>
_renderListProduct
(
item
)
}
/>
/>
{
_renderButtonSubmit
()
}
{
/* {_renderButtonSubmit()} */
}
</
View
>
</
View
>
</
SafeAreaView
>
</
SafeAreaView
>
);
);
...
...
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