forked from stakwork/sphinx-tribes-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stakwork:master' into admin-page
- Loading branch information
Showing
91 changed files
with
2,798 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
export const mockBountyRoles = [ | ||
{ name: 'ADD BOUNTY' }, | ||
{ name: 'UPDATE BOUNTY' }, | ||
{ name: 'DELETE BOUNTY' }, | ||
{ name: 'PAY BOUNTY' }, | ||
{ name: 'VIEW REPORT' } | ||
]; | ||
export const bountyResponse = [ | ||
{ | ||
bounty: { | ||
id: 1384, | ||
owner_id: 'dummy_owner_id', | ||
paid: false, | ||
show: true, | ||
type: 'freelance_job_request', | ||
award: '', | ||
assigned_hours: 0, | ||
bounty_expires: '', | ||
commitment_fee: 0, | ||
price: 250000, | ||
title: 'Lambda Function: Extract files from a zip folder in an s3 bucket', | ||
tribe: 'None', | ||
assignee: 'dummy_assignee_id', | ||
ticket_url: 'https://github.com/stakwork/stak-bounties/issues/9', | ||
org_uuid: 'dummy_org_uuid', | ||
description: 'dummy_description', | ||
wanted_type: 'Web development', | ||
deliverables: '', | ||
github_description: true, | ||
one_sentence_summary: '', | ||
estimated_session_length: 'Less than 3 hours', | ||
estimated_completion_date: '', | ||
created: 1706907671, | ||
updated: '2024-02-02T23:50:20.567929Z', | ||
coding_languages: [] | ||
}, | ||
assignee: { | ||
id: 258, | ||
uuid: 'dummy_assignee_uuid', | ||
owner_pubkey: 'dummy_owner_pubkey', | ||
owner_alias: 'dummy_owner_alias', | ||
unique_name: 'dummy_unique_name', | ||
description: 'dummy_description', | ||
tags: [], | ||
img: 'https://dummy-image-url.com', | ||
created: '2023-12-15T16:35:01.893063Z', | ||
updated: '2024-01-31T14:32:16.852539Z', | ||
unlisted: false, | ||
deleted: false, | ||
last_login: 1706562455, | ||
owner_route_hint: 'dummy_owner_route_hint', | ||
owner_contact_key: 'dummy_owner_contact_key', | ||
price_to_meet: 0, | ||
new_ticket_time: 0, | ||
twitter_confirmed: false, | ||
extras: null, | ||
github_issues: null | ||
}, | ||
owner: { | ||
id: 190, | ||
uuid: 'dummy_owner_uuid', | ||
owner_pubkey: 'dummy_owner_pubkey', | ||
owner_alias: 'dummy_owner_alias', | ||
unique_name: 'dummy_unique_name', | ||
description: 'dummy_description', | ||
tags: [], | ||
img: 'https://dummy-image-url.com', | ||
created: '2023-09-21T22:56:59.255469Z', | ||
updated: '2023-09-21T22:56:59.255469Z', | ||
unlisted: false, | ||
deleted: false, | ||
last_login: 1706730967, | ||
owner_route_hint: 'dummy_owner_route_hint', | ||
owner_contact_key: 'dummy_owner_contact_key', | ||
price_to_meet: 0, | ||
new_ticket_time: 0, | ||
twitter_confirmed: false, | ||
extras: null, | ||
github_issues: null | ||
}, | ||
organization: { | ||
uuid: 'dummy_org_uuid', | ||
name: 'Dummy Organization', | ||
img: 'https://dummy-image-url.com' | ||
} | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Organization } from 'store/main'; | ||
|
||
export const mockOrganizations: Organization[] = [ | ||
{ | ||
bounty_count: 0, | ||
created: '2024-01-03T20:34:09.585609Z', | ||
deleted: false, | ||
id: '51', | ||
img: '', | ||
name: 'TEST_NEW', | ||
owner_pubkey: '03cbb9c01cdcf91a3ac3b543a556fbec9c4c3c2a6ed753e19f2706012a26367ae3', | ||
show: false, | ||
updated: '2024-01-03T20:34:09.585609Z', | ||
uuid: 'cmas9gatu2rvqiev4ur0' | ||
}, | ||
{ | ||
bounty_count: 0, | ||
created: '2024-01-03T20:34:09.585609Z', | ||
deleted: false, | ||
id: '52', | ||
img: '', | ||
name: 'TEST_SECOND', | ||
owner_pubkey: '03cbb9c01cdcf91a3ac3b543a556fbec9c4c3c2a6ed753e19f2706012a26367ae3', | ||
show: false, | ||
updated: '2024-01-03T20:34:09.585609Z', | ||
uuid: 'cmas9gatu2rvqiev4ur0' | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import { ThemeProvider, createTheme } from '@mui/system'; | ||
import { Router } from 'react-router-dom'; | ||
import history from '../../config/history'; | ||
import { withProviders } from '../../providers'; | ||
import { MOCK_ENVIRONMENT_HOOKS } from './constants'; | ||
import { useMockBountyData } from './useMockBountyData'; | ||
import { useMockBountyRoleData } from './useMockBountyRoleData'; | ||
import { useMockDropdownOrganizationData } from './useMockDropdownOrganizationData'; | ||
import { useMockOrganizationsData } from './useMockOrganizationsData'; | ||
import { useMockUsdToSatExchangeRate } from './useMockUsdToSatExchangeRate'; | ||
import { useMockSelfProfileStore } from './useMockSelfProfileStore'; | ||
|
||
export function MockStoreEnvironment({ | ||
children, | ||
hooks = [] | ||
}: { | ||
children: React.ReactNode; | ||
hooks: MOCK_ENVIRONMENT_HOOKS[]; | ||
}) { | ||
const theme = createTheme({ | ||
spacing: 8 | ||
}); | ||
useMockBountyData({ enabled: hooks.includes(MOCK_ENVIRONMENT_HOOKS.BOUNTY_DATA) }); | ||
useMockBountyRoleData({ enabled: hooks.includes(MOCK_ENVIRONMENT_HOOKS.BOUNTY_ROES) }); | ||
useMockDropdownOrganizationData({ | ||
enabled: hooks.includes(MOCK_ENVIRONMENT_HOOKS.DROPDOWN_ORGANIZATION_DATA) | ||
}); | ||
useMockOrganizationsData({ enabled: hooks.includes(MOCK_ENVIRONMENT_HOOKS.ORGANIZATION_DATA) }); | ||
useMockUsdToSatExchangeRate({ | ||
enabled: hooks.includes(MOCK_ENVIRONMENT_HOOKS.USD_TO_SAT_EXCHANGE_RATE) | ||
}); | ||
useMockSelfProfileStore({ enabled: hooks.includes(MOCK_ENVIRONMENT_HOOKS.SELF_PROFILE_STORE) }); | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Router history={history}>{children}</Router> | ||
</ThemeProvider> | ||
); | ||
} | ||
|
||
export default withProviders(MockStoreEnvironment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-disable no-unused-vars */ | ||
export enum MOCK_ENVIRONMENT_HOOKS { | ||
BOUNTY_DATA = 'BOUNTY_DATA', | ||
BOUNTY_ROES = 'BOUNTY_ROES', | ||
DROPDOWN_ORGANIZATION_DATA = 'DROPDOWN_ORGANIZATION_DATA', | ||
ORGANIZATION_DATA = 'ORGANIZATION_DATA', | ||
SELF_PROFILE_STORE = 'SELF_PROFILE_STORE', | ||
USD_TO_SAT_EXCHANGE_RATE = 'USD_TO_SAT_EXCHANGE_RATE' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { bountyResponse } from '__test__/__mockData__/bounty'; | ||
import { useEffect } from 'react'; | ||
import { useStores } from 'store'; | ||
import { transformBountyWithPeopleBounty } from 'store/__test__/util'; | ||
|
||
export const useMockBountyData = ({ enabled }: { enabled: boolean }) => { | ||
const { main } = useStores(); | ||
useEffect(() => { | ||
if (enabled) { | ||
// TODO: should write proper types once its when proper are written or people bounty | ||
main.setPeopleBounties([transformBountyWithPeopleBounty(bountyResponse[0])] as any); | ||
} | ||
}, [main, enabled]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { mockBountyRoles } from '__test__/__mockData__/bounty'; | ||
import { useEffect } from 'react'; | ||
import { useStores } from 'store'; | ||
|
||
export const useMockBountyRoleData = ({ enabled }: { enabled: boolean }) => { | ||
const { main } = useStores(); | ||
useEffect(() => { | ||
if (enabled) { | ||
main.setBountyRoles(mockBountyRoles); | ||
} | ||
}, [main, enabled]); | ||
}; |
19 changes: 19 additions & 0 deletions
19
src/__test__/__mockStore__/useMockDropdownOrganizationData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { mockOrganizations } from '__test__/__mockData__/organization'; | ||
import { useEffect } from 'react'; | ||
import { useStores } from 'store'; | ||
|
||
// This hook will populate the store with mock data for the dropdownOrganizations slice | ||
export const useMockDropdownOrganizationData = ({ | ||
personId, | ||
enabled | ||
}: { | ||
personId?: string; | ||
enabled: boolean; | ||
}) => { | ||
const { main } = useStores(); | ||
useEffect(() => { | ||
if (enabled) { | ||
main.setDropdownOrganizations(mockOrganizations); | ||
} | ||
}, [main, personId, enabled]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { mockOrganizations } from '__test__/__mockData__/organization'; | ||
import { useEffect } from 'react'; | ||
import { useStores } from 'store'; | ||
|
||
// This hook will populate the store with mock data for the organization slice | ||
export const useMockOrganizationsData = ({ enabled }: { enabled: boolean }) => { | ||
const { main } = useStores(); | ||
useEffect(() => { | ||
if (enabled) { | ||
main.setOrganizations(mockOrganizations); | ||
} | ||
}, [main, enabled]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { user } from '__test__/__mockData__/user'; | ||
import { useEffect } from 'react'; | ||
import { useStores } from 'store'; | ||
import { Person } from 'store/main'; | ||
|
||
export const useMockSelfProfileStore = ({ enabled }: { enabled: boolean }) => { | ||
const { ui, main } = useStores(); | ||
|
||
useEffect(() => { | ||
if (enabled) { | ||
ui.setMeInfo(user); | ||
ui.setSelectedPerson(user.id); | ||
const person = { | ||
...user, | ||
unique_name: Math.random().toString(36).substring(7), | ||
tags: [] | ||
} as Person; | ||
main.setActivePerson(person); | ||
} | ||
}, [main, ui, enabled]); | ||
}; |
34 changes: 34 additions & 0 deletions
34
src/__test__/__mockStore__/useMockUsdToSatExchangeRate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useEffect } from 'react'; | ||
import { useStores } from 'store'; | ||
|
||
export const useMockUsdToSatExchangeRate = ({ | ||
time = 100000, | ||
enabled | ||
}: { | ||
time?: number; | ||
enabled: boolean; | ||
}) => { | ||
const { ui } = useStores(); | ||
|
||
useEffect(() => { | ||
if (enabled) { | ||
const getUsdToSatsExchangeRate = () => { | ||
// random rate for 1 usd | ||
const rate = Math.random() || 1; | ||
|
||
// 1 bitcoin is 1 million satoshis | ||
const satoshisInABitcoin = 0.00000001; | ||
ui.setUsdToSatsExchangeRate(rate / satoshisInABitcoin); | ||
}; | ||
|
||
getUsdToSatsExchangeRate(); | ||
const timer = setInterval(() => { | ||
getUsdToSatsExchangeRate(); | ||
}, time); | ||
|
||
return () => { | ||
clearInterval(timer); | ||
}; | ||
} | ||
}, [time, ui, enabled]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.