Commit a309ca17 authored by Max Alekseenko's avatar Max Alekseenko

change min number of txs

parent 2f42b47a
...@@ -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);
......
...@@ -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 ]);
......
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