Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/store review and pre review #30

Open
wants to merge 287 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
287 commits
Select commit Hold shift + click to select a range
ecabf5b
fix: badge-icon type
heronlancellot Aug 7, 2024
4537708
feat: blockchain functions and fetchEASData
RafaDSan Aug 7, 2024
fade9b0
update: badge svg
heronlancellot Aug 7, 2024
a995eda
update: card-review badge-icon name
heronlancellot Aug 7, 2024
a2e52a4
update: date badge
heronlancellot Aug 7, 2024
c04b272
fix: remove gray border star-icon
heronlancellot Aug 7, 2024
2d1df38
update: border-r height 75%
heronlancellot Aug 7, 2024
d09cf8b
fix: date w-full
heronlancellot Aug 7, 2024
517cee6
feat: changing names and paremeters
RafaDSan Aug 7, 2024
09d249b
Merge pull request #3 from heronlancellot/fix/navbar-style
heronlancellot Aug 7, 2024
bc94928
refactor: params to mode to be more legible
heronlancellot Aug 8, 2024
7ec2655
refactor: editableReview to mode write and read
heronlancellot Aug 9, 2024
ebcf1ec
feat: add card-new-review
heronlancellot Aug 9, 2024
84af8c0
update: index with new fluxe
heronlancellot Aug 9, 2024
3b8764f
refactor: navbar-review more legible
heronlancellot Aug 9, 2024
43c88e3
feat: add review store data using zustand
heronlancellot Aug 12, 2024
f18f627
update: use context data wit reviewStore zustand
heronlancellot Aug 12, 2024
5844709
fix: remove submit review button from card-review
heronlancellot Aug 12, 2024
9a1bb95
fix: remove unnused import
heronlancellot Aug 12, 2024
08451ba
feat: add connect wallet if the user isn't connected
heronlancellot Aug 12, 2024
2354442
fix: console error badge svg
heronlancellot Aug 12, 2024
70feaf8
feat: add review interface & udpate comonents using review array
heronlancellot Aug 12, 2024
61ff8fb
update: code legibility
heronlancellot Aug 13, 2024
6576615
feat: add review type file
heronlancellot Aug 13, 2024
c246f4f
update: improve code legibility
heronlancellot Aug 13, 2024
8d4f915
feat: add new line spacing
heronlancellot Aug 13, 2024
2040f9d
feat: move to read review page after submit review
heronlancellot Aug 13, 2024
2a41893
Merge pull request #4 from heronlancellot/feat/mode-write-fluxes
heronlancellot Aug 13, 2024
37b8921
feat: add subtitle in index
heronlancellot Aug 14, 2024
bac6582
feat: add fair-rounds text
heronlancellot Aug 14, 2024
f55c605
Merge pull request #5 from heronlancellot/feat/text-style
heronlancellot Aug 14, 2024
551b832
fix: path-names svg
heronlancellot Aug 15, 2024
b57830e
update: badge type
heronlancellot Aug 19, 2024
9c04f4a
update: badgeListProps to Badge
heronlancellot Aug 19, 2024
5260286
feat: add fluxe to submit review and select the new review
heronlancellot Aug 19, 2024
a3ae480
fix: scrollbar-style
heronlancellot Aug 21, 2024
3e790d5
fix: remove unnused code
heronlancellot Aug 21, 2024
8106974
fix: mobile responsivity
heronlancellot Aug 21, 2024
4b3ab05
fix: card-new-review mobile responsivity
heronlancellot Aug 21, 2024
88661b1
Merge pull request #6 from heronlancellot/feat/style-scrollbar
heronlancellot Aug 21, 2024
536bca7
fix: tablet responsivity
heronlancellot Aug 21, 2024
5e85d76
Merge pull request #7 from heronlancellot/feat/responsivity-devices
heronlancellot Aug 21, 2024
0c221f6
fix: mobile responsivity
heronlancellot Aug 22, 2024
740c50e
Merge pull request #8 from heronlancellot/feat/mobile-responsivity
heronlancellot Aug 22, 2024
4b71d46
feat: add initial version of integration
heronlancellot Aug 26, 2024
d8d395b
update: contract constants
heronlancellot Aug 28, 2024
5439f2f
feat: add getBadge
heronlancellot Aug 28, 2024
395c6a6
update: getBadge
heronlancellot Aug 28, 2024
42f9600
feat: add getBadgeIds
heronlancellot Aug 28, 2024
9746982
update: scorer-id constant
heronlancellot Aug 28, 2024
e261d57
update: getGrantStories
heronlancellot Aug 28, 2024
f286f2d
update: getGrantStories & NavbarReview
heronlancellot Aug 28, 2024
312f043
update: CardReview
heronlancellot Aug 28, 2024
e2fb4f0
update: review tab
heronlancellot Aug 28, 2024
60785bb
update: grant& constants
heronlancellot Aug 28, 2024
8c35504
feat: add arb-one-abi
heronlancellot Aug 28, 2024
26ea1ef
feat: add getGrantProgramScore
heronlancellot Aug 28, 2024
08f9d4e
update: screen style
heronlancellot Aug 28, 2024
fc1ede3
feat: add new column into funding map
heronlancellot Aug 28, 2024
5c88ee9
update: submit-attest
heronlancellot Aug 28, 2024
0405a6c
fix: hovered star funding projects
heronlancellot Aug 28, 2024
90583b6
feat: add new contexts review
heronlancellot Aug 28, 2024
84a13e7
feat: add prefixToIPFSLink
heronlancellot Aug 28, 2024
def2049
update: grant-story & additional adjustments
heronlancellot Aug 28, 2024
94de35c
feat: add averageScore
heronlancellot Aug 28, 2024
32f4eff
feat: add abi & constants addres
heronlancellot Aug 29, 2024
7d67738
feat: add programID programList
heronlancellot Aug 29, 2024
a0d1e52
feat: attemp to fill the programScore programId
heronlancellot Aug 29, 2024
5019413
feat: add new review
heronlancellot Aug 29, 2024
e205346
Merge pull request #9 from heronlancellot/feat/integration-backend
0xneves Aug 29, 2024
ab9b788
fix: remove badge-icon
heronlancellot Aug 29, 2024
3b48bd0
fix: remove unnused code
heronlancellot Aug 29, 2024
ba318e8
fix: remove unnused code
heronlancellot Aug 29, 2024
60f258e
fix: remove unnused code
heronlancellot Aug 29, 2024
dc04b78
refactor: badgeOfficial to Badge name interface
heronlancellot Aug 29, 2024
6507768
refactor: new contract deployments
0xneves Aug 29, 2024
d3e2c37
remove: border
0xneves Aug 29, 2024
a62cc5e
feat: can only submit review while on Arbitrum Chain
0xneves Aug 29, 2024
44cf1bf
fix: imports
0xneves Aug 29, 2024
b0bb3ea
fix: wrong context name and added missing types
0xneves Aug 29, 2024
6bed955
fix: added plural to array context name
0xneves Aug 29, 2024
fe2a1e7
fix: removed unused code
0xneves Aug 29, 2024
dc0d458
fix: badge context and missing types
0xneves Aug 29, 2024
e747675
fix: context name
0xneves Aug 29, 2024
e2fcc8a
fix: removed unused files
0xneves Aug 29, 2024
97a0cf1
refactor: attestation to work on arbitrum
0xneves Aug 29, 2024
50ca895
refactor: docs comments and new getters functions
0xneves Aug 29, 2024
92c0268
refactor: submitAttestation
0xneves Aug 29, 2024
f3fbd7d
fix: identation and imports
0xneves Aug 29, 2024
c51b265
feat: adding prettierrc (seriously in need)
0xneves Aug 29, 2024
05953b7
Merge pull request #1 from 0xneves/feat/integration-backend
heronlancellot Aug 29, 2024
1cc8fe8
feat: make feat: add error handling for getGrantProgramScore function…
FrancoAguzzi Aug 29, 2024
1d11bae
feat: added missing types
0xneves Aug 29, 2024
9077fb0
fix: added missing types
0xneves Aug 29, 2024
1162144
fix: setting grantUID and fixing useless padding bottom
0xneves Aug 29, 2024
a225ee6
fix: review was not receiving correct parameters
0xneves Aug 29, 2024
a24e1d3
feat: migrated newest badges loading to father
0xneves Aug 29, 2024
a132327
fix: imoport order
0xneves Aug 29, 2024
b86bbd4
fix: response var name
0xneves Aug 29, 2024
2a9fb0f
fix: calculating timestaps in number instead
0xneves Aug 29, 2024
3a5f7f8
feat: moving active badges to context
0xneves Aug 29, 2024
b6ba853
fix: glitch where the state was messing the change of tabs
0xneves Aug 29, 2024
ceab54e
Merge pull request #2 from 0xneves/feat/integration-backend
heronlancellot Aug 29, 2024
cc9060f
Merge pull request #10 from heronlancellot/feat/integration-backend
0xneves Aug 29, 2024
db9de93
fix: score with 1 decimals
0xneves Aug 29, 2024
7410314
refactor: better looking star
0xneves Aug 29, 2024
e65a3f9
fix: wrong hover color on star
0xneves Aug 29, 2024
fe1af29
fix: review workflow
0xneves Aug 29, 2024
2d70cdb
fix: handling diferent badges
0xneves Aug 29, 2024
6e13b19
fix: wrong addresses
0xneves Aug 29, 2024
7c2da91
fix: ordering post-submit
0xneves Aug 29, 2024
c8a7108
fix: setting last review as main screen when submitted
0xneves Aug 29, 2024
020fc86
Merge pull request #11 from 0xneves/feat/grant-review
0xneves Aug 29, 2024
c5f1fe8
fix: cors throwin error and reseting context when url changes
0xneves Aug 30, 2024
6387694
Merge branch 'blockful-io:feat/grant-review' into feat/grant-review
0xneves Aug 30, 2024
8536b59
Merge pull request #12 from 0xneves/feat/grant-review
0xneves Aug 30, 2024
e92b346
update: card-new-review doc & code improvement
heronlancellot Aug 30, 2024
fcc7d93
Merge pull request #14 from blockful-io/feat/grant-review
0xneves Aug 30, 2024
8d7e0fa
fix: remove abi
heronlancellot Aug 30, 2024
26cd594
refactor: functions to retrieve data blockchain
heronlancellot Aug 30, 2024
847a931
update: functions & types
heronlancellot Aug 30, 2024
934e674
update: contract-addresses
heronlancellot Aug 30, 2024
42f11ea
feat: add tooltip into program-list
heronlancellot Aug 30, 2024
ead0ee0
refactor: chevron-down color
heronlancellot Aug 30, 2024
4e1d864
fix: remove the negation, to check if grantee is equal the connected …
heronlancellot Aug 30, 2024
14c9154
fix: remove console.log
heronlancellot Aug 30, 2024
5d1a73c
Merge pull request #13 from heronlancellot/feat/small-improvements-code
heronlancellot Aug 30, 2024
11b4ef1
feat: add timestamp-difference function between timestamps
heronlancellot Sep 23, 2024
033a386
feat: add avarageTimeDifference
heronlancellot Sep 23, 2024
f9fd6e6
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
c339d0d
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
8d532d5
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
bf623c9
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
d2a42a6
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
e991929
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
31caf0b
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
6b53954
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Sep 23, 2024
321d20c
fix: fix type error
FrancoAguzzi Sep 24, 2024
8b6faa8
Merge pull request #20 from blockful-io/hotfix/fix-type-error
FrancoAguzzi Sep 24, 2024
4dcc199
fix: update addresses to new contracts
FrancoAguzzi Sep 24, 2024
1b4ed7d
fix: update reviewer enabling conditional
FrancoAguzzi Sep 24, 2024
7ae2bc7
fix: remove estimateGas from attest function
FrancoAguzzi Sep 24, 2024
0ab27cb
fix: update walletClient usage inside submitAttest
FrancoAguzzi Sep 24, 2024
1ef9968
fix: update sendTransaction call inside submitAttest
FrancoAguzzi Sep 24, 2024
fd611ab
fix: enable reviews only when connected to Arbitrum
FrancoAguzzi Sep 24, 2024
ccb8170
fix: ask user to switch chain when wants to do a review but is not at…
FrancoAguzzi Sep 24, 2024
0845bfb
fix: update submitAttest to another switchChain method
FrancoAguzzi Sep 24, 2024
5a88b96
fix: update submitAttest to another switchChain method
FrancoAguzzi Sep 24, 2024
e741e69
fix: remove repeated conditionals
FrancoAguzzi Sep 24, 2024
d241d9d
fix: do not mismatch toast message on reverted transaction
FrancoAguzzi Sep 24, 2024
8b0f364
Merge pull request #21 from blockful-io/hotfix/update-contracts-address
FrancoAguzzi Sep 24, 2024
a3758ea
feat: add new review design style
heronlancellot Oct 2, 2024
659b3a5
Merge pull request #25 from heronlancellot/feat/new-design-style
heronlancellot Oct 2, 2024
3030d4f
feat: add review-summary
heronlancellot Oct 2, 2024
0b0c272
feat: add stories lenght data
heronlancellot Oct 3, 2024
140eb24
update: card-review-summary style
heronlancellot Oct 3, 2024
9a86088
Update components/Pages/Project/Review/NavbarReview.tsx
FrancoAguzzi Oct 3, 2024
437f074
feat: add progress-bar & adjust style
heronlancellot Oct 3, 2024
e44c507
fix: mobile adjustements
heronlancellot Oct 3, 2024
0f93679
Merge branch 'dev' into feat/timestamp-difference
heronlancellot Oct 3, 2024
e27fcf1
Merge pull request #18 from heronlancellot/feat/timestamp-difference
heronlancellot Oct 3, 2024
6c3ba0b
Merge branch 'dev' into feat/card-review-summary
heronlancellot Oct 3, 2024
9977b77
feat: add average review
heronlancellot Oct 3, 2024
47fffe3
feat: add average review star
heronlancellot Oct 3, 2024
8d1696d
feat: add comments
heronlancellot Oct 3, 2024
65ade56
feat: add card-review-summary timestamp total review
heronlancellot Oct 4, 2024
6a57619
feat: add rating score filtered
heronlancellot Oct 4, 2024
0ce47b9
update: percentage fixed value
heronlancellot Oct 4, 2024
67c6a92
feat: adjusting style
heronlancellot Oct 4, 2024
97fafda
update: text-center into mobile
heronlancellot Oct 4, 2024
4153f39
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
35ef5f0
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
96bb41a
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
862243c
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
22fa8fc
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
6c584e7
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
9354697
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
adf3db7
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
aa2a99f
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
f0fd7f3
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
d173c0a
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
e0ebf1f
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
c9577d8
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
4c408dd
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
f25b68b
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
127ba16
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
161d8f9
Update components/Pages/Project/Review/CardReviewSummary.tsx
heronlancellot Oct 4, 2024
4c1e749
fix: interval-message-mocked-data
heronlancellot Oct 4, 2024
1519694
update: Progress-Bar variable name
heronlancellot Oct 4, 2024
cdaa963
feat: add reviews-history style
heronlancellot Oct 4, 2024
483fc57
update: navbar-selection review style
heronlancellot Oct 4, 2024
1fa5a9e
update: navbar review style
heronlancellot Oct 4, 2024
3465917
update: star icon color
heronlancellot Oct 7, 2024
f202af2
update: styles dark/light mode
heronlancellot Oct 7, 2024
8b43ae0
update: review summary percentage
heronlancellot Oct 7, 2024
e442c17
update: file name to constants/index & remove unnused code
heronlancellot Oct 7, 2024
cf61358
update: card-new-review with corrected interfaces from backend & upda…
heronlancellot Oct 7, 2024
39fe99c
feat: rename react state, define interfaces out of the component, sma…
FrancoAguzzi Oct 7, 2024
6a6d684
fix: remove extra blank line
FrancoAguzzi Oct 7, 2024
aa230c5
Merge pull request #26 from heronlancellot/feat/card-review-summary
FrancoAguzzi Oct 7, 2024
854afff
feat: add card-new-review api call
heronlancellot Oct 7, 2024
a4e1550
Merge branch 'dev' into feat/reviews-history
heronlancellot Oct 7, 2024
fba6291
fix: style text light mode
heronlancellot Oct 8, 2024
52473d5
feat: add ArrowNavigationBar
heronlancellot Oct 8, 2024
1e3e09c
Update components/Pages/Project/Review/ArrowNavigationBar.tsx
heronlancellot Oct 9, 2024
18409f2
Update utilities/review/constants/index.ts
heronlancellot Oct 9, 2024
2e91483
Update utilities/review/constants/index.ts
heronlancellot Oct 9, 2024
902922e
Update utilities/review/constants/index.ts
heronlancellot Oct 9, 2024
c494b39
Update utilities/review/constants/index.ts
heronlancellot Oct 9, 2024
298762e
Update utilities/review/constants/index.ts
heronlancellot Oct 9, 2024
61f57bc
Update styles/globals.css
heronlancellot Oct 9, 2024
028abf0
Update components/Pages/Project/Review/Skeleton.tsx
heronlancellot Oct 9, 2024
d284e48
Update components/Pages/Project/Review/NavbarReview.tsx
heronlancellot Oct 9, 2024
d863125
Update components/Pages/Project/Review/CardNewReview.tsx
heronlancellot Oct 9, 2024
bdbf6f1
Update components/Pages/Project/Review/CardNewReview.tsx
heronlancellot Oct 9, 2024
b312d52
fix: variable names
heronlancellot Oct 9, 2024
9d64f02
fix: interface with dynamic data
heronlancellot Oct 9, 2024
222c50f
fix: card-new-review unnused code & add toast
heronlancellot Oct 9, 2024
6ca0747
fix: remove hardcoded date
heronlancellot Oct 9, 2024
b6850ae
update: api interface
heronlancellot Oct 9, 2024
a369189
feat: add card-new-review-railway-backend-constant
heronlancellot Oct 11, 2024
1ba7c3c
feat: add programId optionally into pre-review-request
heronlancellot Oct 11, 2024
50a6709
update: grant-UID & program-UID retrieved by params
heronlancellot Oct 14, 2024
6e81d81
fix: interface to interface inline
heronlancellot Oct 14, 2024
a11ba44
update: contract-call
heronlancellot Oct 14, 2024
8931ec4
feat: added new deployed contracts
RafaDSan Oct 15, 2024
53fe8f9
fix: checking storie before proceed
RafaDSan Oct 15, 2024
b5cf599
fix: correct grantProgramId type in schema
RafaDSan Oct 15, 2024
1358143
fix: fixed smart contracts updated
RafaDSan Oct 15, 2024
d61bde4
fix: fixed error when null badges
RafaDSan Oct 15, 2024
07d1a59
fix: fixed error when undefined scores
RafaDSan Oct 15, 2024
8c1f73a
fix: align grantUID and programUID usage in review forms
FrancoAguzzi Oct 16, 2024
601ba03
feat: add card-new-review
heronlancellot Oct 17, 2024
85dea64
update: card-review ratings without data
heronlancellot Oct 17, 2024
a351077
fix(reviews): fixed request payload for badgesScores and activeBadgeIds
hawkjr97 Oct 31, 2024
51e5782
test commit
hawkjr97 Nov 1, 2024
2a64637
test commit
hawkjr97 Nov 1, 2024
cc4a3dd
feat(reviews): implement review permission check for gap users only
hawkjr97 Nov 4, 2024
5c2a75b
refactor: improve async fetch
hawkjr97 Nov 4, 2024
07c9994
fix: set isGapUser as boolean
FrancoAguzzi Nov 6, 2024
9dd9e65
Update components/Pages/Project/Review/CardNewReview.tsx
FrancoAguzzi Nov 6, 2024
63e2d5b
Update components/Pages/Project/Review/ArrowNavigationBar.tsx
FrancoAguzzi Nov 6, 2024
05b20a7
Update components/Pages/Project/Review/ArrowNavigationBar.tsx
FrancoAguzzi Nov 6, 2024
4a707a8
Update components/Pages/Project/Review/CardNewReview.tsx
FrancoAguzzi Nov 6, 2024
58e48ad
Update package.json
FrancoAguzzi Nov 6, 2024
5384bae
Update components/Pages/Project/Review/CardNewReview.tsx
FrancoAguzzi Nov 6, 2024
500f0c4
Update components/Pages/Project/Review/CardNewReview.tsx
FrancoAguzzi Nov 6, 2024
b8484e3
Update components/Pages/Project/Review/ArrowNavigationBar.tsx
FrancoAguzzi Nov 6, 2024
3bfac2d
Merge pull request #28 from heronlancellot/feat/reviews-history
FrancoAguzzi Nov 6, 2024
287bf14
chore: update comment for better doc. understandment
FrancoAguzzi Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions components/Pages/Project/Review/NavbarReview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
"use client";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { useReviewStore } from "@/store/review";
import { useSearchParams } from "next/navigation";

Expand All @@ -23,6 +24,34 @@ export const NavbarReview = () => {
const setIsStarSelected = useReviewStore((state: any) => state.setIsStarSelected);

const searchParams = useSearchParams();
const setTimestamp = useReviewStore((state: any) => state.setTimestamp);
const [timeDifference, setTimeDifference] = useState<number[]>([]);
const [averageTimeDifference, setAverageTimeDifference] = useState<number | undefined>(undefined);

const getTimestampDifferenceBetweenTimestamps = (
timestamps: number[],
grantStoriesLenght: number,
) => {
const timeDifferenceBetweenTimestamps: number[] = [];

for (let i = 0; i < timestamps.length - 1; i++) {
/**
* The difference between two timestamps in the received
* array is the gap time between these two grant reviews.
*/
timeDifferenceBetweenTimestamps.push(timestamps[i] - timestamps[i + 1]);
}

setTimeDifference(timeDifferenceSorted);
const timeDifferenceSum = timeDifferenceSorted.reduce(
(accumulator, current) => Number(accumulator) + Number(current),
0,
);
/**
* Below we calculate the average time that it takes for the given grant to receive a new review
*/
setAvarageTimeDifference(timeDifferenceSum / grantStoriesLenght);
};

useEffect(() => {
const grantIdFromQueryParam = searchParams?.get("grantId");
Expand All @@ -41,6 +70,13 @@ export const NavbarReview = () => {
const fetchGrantStories = async () => {
const grantStories = await getGrantStories(grantUID);
setStories(grantStories);
if (grantStories) {
const timestamps = grantStories
.sort((a: any, b: any) => Number(b.timestamp) - Number(a.timestamp))
.map((grantStorie) => grantStorie.timestamp);
setTimestamp(timestamps);
getTimestampDifferenceBetweenTimestamps(timestamps, grantStories.length);
}
};

const handleToggleReviewSelected = (id: number) => {
Expand Down Expand Up @@ -83,7 +119,15 @@ export const NavbarReview = () => {
</div>
)}
{index < stories.length - 1 && (
<div className="absolute right-0 top-1/2 h-3/4 w-[2px] bg-zinc-300 transform -translate-y-1/2"></div>
<>
<div className="absolute right-0 top-1/2 h-3/4 w-0.5 bg-zinc-300 transform -translate-y-1/2">
<p className="flex">
{Number(timeDifference[index]) / 86400 >= 1
? `${Math.ceil(Number(timeDifference[index]) / 86400)} days`
: "Less than 1 day"}
</p>
</div>
</>
)}
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions store/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ interface ReviewStore {
// Used to store the array of scores that the user has given to each active badge
badgeScores: number[];
setBadgeScores: (badgeScores: number[]) => void;

timestamp: number[];
setTimestamp: (timestamp: number[]) => void;
}

export const useReviewStore = create<ReviewStore>((set: any, get: any) => ({
Expand All @@ -54,4 +57,7 @@ export const useReviewStore = create<ReviewStore>((set: any, get: any) => ({
set((state: any) => ({ ...state, activeBadgeIds })),
badgeScores: [],
setBadgeScores: (badgeScores: number[]) => set((state: any) => ({ ...state, badgeScores })),

timestamp: [],
setTimestamp: (timestamp: number[]) => set((state: any) => ({ ...state, timestamp })),
}));