Skip to content

Commit

Permalink
Merge pull request stakwork#777 from stakwork/feat/admin_hunters_stats
Browse files Browse the repository at this point in the history
Feat: add new hunters admin data
  • Loading branch information
elraphty authored Dec 17, 2024
2 parents d6ffbdb + ec8aae6 commit 6f206ff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pages/superadmin/statistics/StatisticsStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const UpperCardWrapper = styled.div`
export const BelowCardWrapper = styled.div`
flex: 1;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-columns: repeat(4, 1fr);
gap: 2em;
`;

Expand Down
13 changes: 9 additions & 4 deletions src/pages/superadmin/statistics/__tests__/Statistics.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { setupStore } from '../../../../__test__/__mockData__/setupStore';
import { user } from '../../../../__test__/__mockData__/user';
import { mockUsehistory } from '../../../../__test__/__mockFn__/useHistory';
import { Statistics } from '../';
import { bounties } from 'pages/superadmin/tableComponent/mockBountyData';

beforeAll(() => {
nock.disableNetConnect();
Expand All @@ -29,7 +28,9 @@ const mockMetrics = {
average_paid: 10,
average_completed: 1,
unique_hunters_paid: 7,
new_hunters_paid: 2
new_hunters_paid: 2,
new_hunters: 4,
new_hunters_by_period: 10
};

describe('Statistics Component', () => {
Expand Down Expand Up @@ -82,7 +83,9 @@ describe('Statistics Component', () => {
average_paid: 10,
average_completed: 1,
unique_hunters_paid: 7,
new_hunters_paid: 2
new_hunters_paid: 2,
new_hunters: 4,
new_hunters_by_period: 10
};

const { getByText } = render(<Statistics metrics={lowPercentageMetrics} />);
Expand All @@ -100,7 +103,9 @@ describe('Statistics Component', () => {
average_paid: 10,
average_completed: 1,
unique_hunters_paid: 7,
new_hunters_paid: 2
new_hunters_paid: 2,
new_hunters: 4,
new_hunters_by_period: 10
};

const { getByText } = render(<Statistics metrics={lowPercentageMetrics} />);
Expand Down
14 changes: 14 additions & 0 deletions src/pages/superadmin/statistics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ export const Statistics = ({ freezeHeaderRef, metrics }: StatisticsProps) => (
<Title>{convertToLocaleString(metrics?.new_hunters_paid || 0)}</Title>
<Subheading width="120px">First Bounty Paid</Subheading>
</div>
<VerticaGrayLine />
</DivWrapper>
<DivWrapper>
<div>
<Title>{convertToLocaleString(metrics?.new_hunters_by_period || 0)}</Title>
<Subheading width="120px">Hunters At Start Of Period</Subheading>
</div>
<VerticaGrayLine />
</DivWrapper>
<DivWrapper>
<div>
<Title>{convertToLocaleString(metrics?.new_hunters || 0)}</Title>
<Subheading width="120px">New Hunters</Subheading>
</div>
</DivWrapper>
</BelowCardWrapper>
</CardHunter>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/superadmin/utils/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export const normalizeMetrics = (data: any): BountyMetrics => ({
average_paid: data.average_paid || data.AveragePaid,
average_completed: data.average_completed || data.AverageCompleted,
unique_hunters_paid: data.unique_hunters_paid || data.uniqueHuntersPaid,
new_hunters_paid: data.new_hunters_paid || data.newHuntersPaid
new_hunters_paid: data.new_hunters_paid || data.newHuntersPaid,
new_hunters: data.new_hunters || data.newHunters,
new_hunters_by_period: data.new_hunters_by_period || data.newHuntersByPeriod
});
2 changes: 2 additions & 0 deletions src/store/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ export interface BountyMetrics {
average_completed: number;
unique_hunters_paid: number;
new_hunters_paid: number;
new_hunters: number;
new_hunters_by_period: number;
}

export interface BountyStatus {
Expand Down

0 comments on commit 6f206ff

Please sign in to comment.