From 059fbde7c6e709ee70f8bcf5137ec6f2dbe1b459 Mon Sep 17 00:00:00 2001 From: elraphty Date: Fri, 29 Dec 2023 13:49:29 +0100 Subject: [PATCH 1/2] removed mocked data --- db/structs.go | 1 + frontend/app/src/pages/superadmin/index.tsx | 21 +++++-- .../pages/superadmin/tableComponent/index.tsx | 63 +++++++++++++------ frontend/app/src/store/main.ts | 4 +- handlers/metrics.go | 1 + 5 files changed, 64 insertions(+), 26 deletions(-) diff --git a/db/structs.go b/db/structs.go index 47ed1efbf..f65d996a3 100644 --- a/db/structs.go +++ b/db/structs.go @@ -395,6 +395,7 @@ type BountyData struct { Person AssigneeAlias string `json:"assignee_alias"` AssigneeId uint `json:"assignee_id"` + AssigneeImg string `json:"assignee_img"` AssigneeCreated *time.Time `json:"assignee_created"` AssigneeUpdated *time.Time `json:"assignee_updated"` AssigneeDescription string `json:"assignee_description"` diff --git a/frontend/app/src/pages/superadmin/index.tsx b/frontend/app/src/pages/superadmin/index.tsx index bbde861f0..a21c75118 100644 --- a/frontend/app/src/pages/superadmin/index.tsx +++ b/frontend/app/src/pages/superadmin/index.tsx @@ -3,12 +3,11 @@ * To enable colaborations */ -import React, { useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import styled from 'styled-components'; -// import { useStores } from 'store'; +import { useStores } from 'store'; import moment from 'moment'; import { MyTable } from './tableComponent'; -import { bounties } from './tableComponent/mockBountyData'; import { Header } from './header'; import { Statistics } from './statistics'; import AdminAccessDenied from './accessDenied'; @@ -22,8 +21,9 @@ const Container = styled.body` export const SuperAdmin = () => { //Todo: Remove all comments when metrcis development is done - // const { main, ui } = useStores(); + const { main } = useStores(); const [isSuperAdmin] = useState(true); + const [apibounties, setBounties] = useState([]); /** * Todo use the same date range, @@ -43,6 +43,17 @@ export const SuperAdmin = () => { // } // }, [main, ui, getIsSuperAdmin]); + const getBounties = useCallback(async () => { + if (startDate && endDate) { + const bounties = await main.getBountiesByRange(String(startDate), String(endDate)); + setBounties(bounties); + } + }, [main, startDate, endDate]); + + useEffect(() => { + getBounties(); + }, [getBounties]); + return ( <> {!isSuperAdmin ? ( @@ -51,7 +62,7 @@ export const SuperAdmin = () => {
- + )} diff --git a/frontend/app/src/pages/superadmin/tableComponent/index.tsx b/frontend/app/src/pages/superadmin/tableComponent/index.tsx index 19bc7e41e..be173579e 100644 --- a/frontend/app/src/pages/superadmin/tableComponent/index.tsx +++ b/frontend/app/src/pages/superadmin/tableComponent/index.tsx @@ -1,8 +1,10 @@ import React, { useCallback, useEffect, useState } from 'react'; import styled from 'styled-components'; import { useStores } from 'store'; +import moment from 'moment'; import paginationarrow1 from '../header/icons/paginationarrow1.svg'; import paginationarrow2 from '../header/icons/paginationarrow2.svg'; +import defaultPic from '../../../public/static/profile_avatar.svg'; import copygray from '../header/icons/copygray.svg'; import { @@ -259,25 +261,48 @@ export const MyTable = ({ bounties, startDate, endDate }: TableProps) => { Status - {currentPageData()?.map((bounty: any) => ( - - {bounty?.title} - {bounty?.date} - {bounty?.dtgp} - - - - - - - - - - - - - - ))} + {currentPageData()?.map((bounty: any) => { + const bounty_status = + bounty?.paid && bounty.assignee + ? 'completed' + : bounty.assignee && !bounty.paid + ? 'assigned' + : 'open'; + + const created = moment.unix(bounty.bounty_created).format('YYYY-MM-DD'); + const time_to_pay = bounty.paid_date + ? moment(bounty.paid_date).diff(created, 'days') + : 0; + + return ( + + {bounty?.title} + {created} + {time_to_pay} + + + + + + + + + + + + + + ); + })} diff --git a/frontend/app/src/store/main.ts b/frontend/app/src/store/main.ts index eef8aad48..4458ab94a 100644 --- a/frontend/app/src/store/main.ts +++ b/frontend/app/src/store/main.ts @@ -2423,7 +2423,7 @@ export class MainStore { } } - async getBountiesByRange(start_date: number, end_date: number): Promise { + async getBountiesByRange(start_date: string, end_date: string): Promise { try { if (!uiStore.meInfo) return undefined; const info = uiStore.meInfo; @@ -2443,7 +2443,7 @@ export class MainStore { } }); - return r; + return r.json(); } catch (e) { console.error('getBountyMetrics', e); return undefined; diff --git a/handlers/metrics.go b/handlers/metrics.go index bd28524a1..f5873c8fe 100644 --- a/handlers/metrics.go +++ b/handlers/metrics.go @@ -256,6 +256,7 @@ func GetMetricsBountiesData(metricBounties []db.Bounty) []db.BountyData { BountyDescription: bounty.Description, BountyUpdated: bounty.Updated, AssigneeId: bountyAssignee.ID, + AssigneeImg: bountyAssignee.Img, AssigneeAlias: bountyAssignee.OwnerAlias, AssigneeDescription: bountyAssignee.Description, AssigneeRouteHint: bountyAssignee.OwnerRouteHint, From 3fa47ee0ed07b2f6d0ae33134df83d17cf5cc3f5 Mon Sep 17 00:00:00 2001 From: elraphty Date: Fri, 29 Dec 2023 13:53:56 +0100 Subject: [PATCH 2/2] renamed apibounties to bounties --- frontend/app/src/pages/superadmin/index.tsx | 4 ++-- frontend/app/src/pages/superadmin/tableComponent/index.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/app/src/pages/superadmin/index.tsx b/frontend/app/src/pages/superadmin/index.tsx index a21c75118..3fcef4a14 100644 --- a/frontend/app/src/pages/superadmin/index.tsx +++ b/frontend/app/src/pages/superadmin/index.tsx @@ -23,7 +23,7 @@ export const SuperAdmin = () => { //Todo: Remove all comments when metrcis development is done const { main } = useStores(); const [isSuperAdmin] = useState(true); - const [apibounties, setBounties] = useState([]); + const [bounties, setBounties] = useState([]); /** * Todo use the same date range, @@ -62,7 +62,7 @@ export const SuperAdmin = () => {
- + )} diff --git a/frontend/app/src/pages/superadmin/tableComponent/index.tsx b/frontend/app/src/pages/superadmin/tableComponent/index.tsx index be173579e..90ba660ed 100644 --- a/frontend/app/src/pages/superadmin/tableComponent/index.tsx +++ b/frontend/app/src/pages/superadmin/tableComponent/index.tsx @@ -5,8 +5,8 @@ import moment from 'moment'; import paginationarrow1 from '../header/icons/paginationarrow1.svg'; import paginationarrow2 from '../header/icons/paginationarrow2.svg'; import defaultPic from '../../../public/static/profile_avatar.svg'; - import copygray from '../header/icons/copygray.svg'; + import { TableContainer, HeaderContainer,