Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
vicotor
frontend
Commits
a309ca17
Commit
a309ca17
authored
Jul 22, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change min number of txs
parent
2f42b47a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
useRatings.test.tsx
ui/marketplace/Rating/useRatings.test.tsx
+6
-6
useRatings.tsx
ui/marketplace/Rating/useRatings.tsx
+3
-1
No files found.
ui/marketplace/Rating/useRatings.test.tsx
View file @
a309ca17
...
@@ -13,11 +13,11 @@ beforeEach(() => {
...
@@ -13,11 +13,11 @@ beforeEach(() => {
jest
.
clearAllMocks
();
jest
.
clearAllMocks
();
});
});
it
(
'
should set canRate to true if address is defined and transactions_count is
10
or more
'
,
async
()
=>
{
it
(
'
should set canRate to true if address is defined and transactions_count is
5
or more
'
,
async
()
=>
{
useAccount
.
mockReturnValue
({
address
:
'
0x123
'
});
useAccount
.
mockReturnValue
({
address
:
'
0x123
'
});
useApiQuery
.
mockReturnValue
({
useApiQuery
.
mockReturnValue
({
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
{
transactions_count
:
10
},
data
:
{
transactions_count
:
5
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
expect
(
result
.
current
.
canRate
).
toBe
(
true
);
expect
(
result
.
current
.
canRate
).
toBe
(
true
);
...
@@ -27,17 +27,17 @@ it('should set canRate to undefined if address is undefined', async() => {
...
@@ -27,17 +27,17 @@ it('should set canRate to undefined if address is undefined', async() => {
useAccount
.
mockReturnValue
({
address
:
undefined
});
useAccount
.
mockReturnValue
({
address
:
undefined
});
useApiQuery
.
mockReturnValue
({
useApiQuery
.
mockReturnValue
({
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
{
transactions_count
:
10
},
data
:
{
transactions_count
:
5
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
expect
(
result
.
current
.
canRate
).
toBe
(
undefined
);
expect
(
result
.
current
.
canRate
).
toBe
(
undefined
);
});
});
it
(
'
should set canRate to false if transactions_count is less than
10
'
,
async
()
=>
{
it
(
'
should set canRate to false if transactions_count is less than
5
'
,
async
()
=>
{
useAccount
.
mockReturnValue
({
address
:
'
0x123
'
});
useAccount
.
mockReturnValue
({
address
:
'
0x123
'
});
useApiQuery
.
mockReturnValue
({
useApiQuery
.
mockReturnValue
({
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
{
transactions_count
:
5
},
data
:
{
transactions_count
:
4
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
...
@@ -47,7 +47,7 @@ it('should set canRate to false if isPlaceholderData is true', async() => {
...
@@ -47,7 +47,7 @@ it('should set canRate to false if isPlaceholderData is true', async() => {
useAccount
.
mockReturnValue
({
address
:
'
0x123
'
});
useAccount
.
mockReturnValue
({
address
:
'
0x123
'
});
useApiQuery
.
mockReturnValue
({
useApiQuery
.
mockReturnValue
({
isPlaceholderData
:
true
,
isPlaceholderData
:
true
,
data
:
{
transactions_count
:
10
},
data
:
{
transactions_count
:
5
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
...
...
ui/marketplace/Rating/useRatings.tsx
View file @
a309ca17
...
@@ -11,6 +11,8 @@ import type { EventTypes, EventPayload } from 'lib/mixpanel/index';
...
@@ -11,6 +11,8 @@ import type { EventTypes, EventPayload } from 'lib/mixpanel/index';
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
{
ADDRESS_COUNTERS
}
from
'
stubs/address
'
;
import
{
ADDRESS_COUNTERS
}
from
'
stubs/address
'
;
const
MIN_TRANSACTION_COUNT
=
5
;
const
feature
=
config
.
features
.
marketplace
;
const
feature
=
config
.
features
.
marketplace
;
const
airtable
=
(
feature
.
isEnabled
&&
feature
.
rating
)
?
const
airtable
=
(
feature
.
isEnabled
&&
feature
.
rating
)
?
new
Airtable
({
apiKey
:
feature
.
rating
.
airtableApiKey
}).
base
(
feature
.
rating
.
airtableBaseId
)
:
new
Airtable
({
apiKey
:
feature
.
rating
.
airtableApiKey
}).
base
(
feature
.
rating
.
airtableBaseId
)
:
...
@@ -109,7 +111,7 @@ export default function useRatings() {
...
@@ -109,7 +111,7 @@ export default function useRatings() {
useEffect
(()
=>
{
useEffect
(()
=>
{
const
{
isPlaceholderData
,
data
}
=
addressCountersQuery
;
const
{
isPlaceholderData
,
data
}
=
addressCountersQuery
;
const
canRate
=
address
&&
!
isPlaceholderData
&&
Number
(
data
?.
transactions_count
)
>=
10
;
const
canRate
=
address
&&
!
isPlaceholderData
&&
Number
(
data
?.
transactions_count
)
>=
MIN_TRANSACTION_COUNT
;
setCanRate
(
canRate
);
setCanRate
(
canRate
);
},
[
address
,
addressCountersQuery
]);
},
[
address
,
addressCountersQuery
]);
...
...
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