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: show venue #74

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
61f88a7
fix img
Taump Aug 8, 2022
6a232b8
Merge branch 'master' of github.com:Taump/prediction-markets-ui
Taump Aug 8, 2022
809bc2b
Merge branch 'byteball:master' into master
Taump Aug 8, 2022
ba25a5a
Merge branch 'byteball:master' into master
Taump Aug 8, 2022
276fbc0
Merge branch 'byteball:master' into master
Taump Aug 9, 2022
4ba8833
Merge branch 'byteball:master' into master
Taump Aug 9, 2022
d5bcd70
Merge branch 'byteball:master' into master
Taump Aug 9, 2022
7f35adb
Merge branch 'byteball:master' into master
Taump Aug 9, 2022
7c34a73
Merge branch 'byteball:master' into master
Taump Aug 10, 2022
66638c5
Merge branch 'byteball:master' into master
Taump Aug 11, 2022
08fc8f7
Merge branch 'byteball:master' into master
Taump Aug 15, 2022
e07f0fd
Merge branch 'byteball:master' into master
Taump Aug 15, 2022
e63cb19
Merge branch 'byteball:master' into master
Taump Aug 16, 2022
0b2a720
Merge branch 'byteball:master' into master
Taump Aug 17, 2022
eaa5e1d
Merge branch 'byteball:master' into master
Taump Aug 17, 2022
5b06235
Merge branch 'byteball:master' into master
Taump Aug 26, 2022
cc1249e
Merge branch 'byteball:master' into master
Taump Aug 26, 2022
7ee8f18
Merge branch 'byteball:master' into master
Taump Aug 29, 2022
cd8f065
Merge branch 'byteball:master' into master
Taump Aug 30, 2022
ed826f7
Merge branch 'byteball:master' into master
Taump Sep 1, 2022
48724f3
Merge branch 'byteball:master' into master
Taump Sep 2, 2022
1861b1c
Merge branch 'byteball:master' into master
Taump Sep 5, 2022
468105d
Merge branch 'byteball:master' into master
Taump Sep 6, 2022
cb6036d
Merge branch 'byteball:master' into master
Taump Sep 9, 2022
3b2545f
Merge branch 'byteball:master' into master
Taump Sep 16, 2022
3da0206
Merge branch 'byteball:master' into master
Taump Sep 16, 2022
d1994ca
Merge branch 'byteball:master' into master
Taump Sep 20, 2022
919d8a1
Merge branch 'byteball:master' into master
Taump Sep 23, 2022
3ce3792
Merge branch 'byteball:master' into master
Taump Sep 27, 2022
04047c3
Merge branch 'byteball:master' into master
Taump Oct 3, 2022
3ac0c36
Merge branch 'byteball:master' into master
Taump Oct 4, 2022
2dcd653
Merge branch 'byteball:master' into master
Taump Oct 4, 2022
2dbce46
Merge branch 'byteball:master' into master
Taump Oct 4, 2022
62675b8
Merge branch 'byteball:master' into master
Taump Oct 4, 2022
ae6e6be
Merge branch 'byteball:master' into master
Taump Oct 5, 2022
442dea8
Merge branch 'byteball:master' into master
Taump Oct 5, 2022
83d7353
Merge branch 'byteball:master' into master
Taump Oct 6, 2022
71c96c4
Merge branch 'byteball:master' into master
Taump Oct 7, 2022
a158130
Merge branch 'byteball:master' into master
Taump Oct 9, 2022
b4a449b
Merge branch 'byteball:master' into master
Taump Oct 9, 2022
d4e0546
Merge branch 'byteball:master' into master
Taump Oct 10, 2022
2284a5f
Merge branch 'byteball:master' into master
Taump Oct 11, 2022
9d570d4
Merge branch 'byteball:master' into master
Taump Oct 18, 2022
d702a58
Merge branch 'byteball:master' into master
Taump Oct 18, 2022
806ea8a
Merge branch 'byteball:master' into master
Taump Oct 31, 2022
5c3a1a9
Merge branch 'byteball:master' into master
Taump Oct 31, 2022
efb68b5
Merge branch 'byteball:master' into master
Taump Nov 21, 2022
f3571a7
Merge branch 'byteball:master' into master
Taump Nov 22, 2022
de9619d
Merge branch 'byteball:master' into master
Taump Dec 5, 2022
dbde1a1
Merge branch 'byteball:master' into master
Taump Dec 8, 2022
2caf538
Merge branch 'byteball:master' into master
Taump Jan 7, 2023
6fad2fa
Merge branch 'byteball:master' into master
Taump Feb 10, 2023
12c903f
Merge branch 'byteball:master' into master
Taump Feb 13, 2023
04c1eed
Merge branch 'byteball:master' into master
Taump Apr 2, 2024
85f505e
Merge branch 'byteball:master' into master
Taump Apr 4, 2024
df1ad96
Merge branch 'byteball:master' into master
Taump Apr 7, 2024
47315ca
Merge branch 'byteball:master' into master
Taump Apr 7, 2024
64a52fe
Merge branch 'byteball:master' into master
Taump Apr 9, 2024
0176b14
Merge branch 'byteball:master' into master
Taump Apr 9, 2024
ecd71e0
Merge branch 'byteball:master' into master
Taump Apr 9, 2024
9f64842
Merge branch 'byteball:master' into master
Taump Jun 5, 2024
a760925
Merge branch 'byteball:master' into master
Taump Jun 7, 2024
9a9f8b5
Merge branch 'byteball:master' into master
Taump Jun 13, 2024
9980498
Merge branch 'byteball:master' into master
Taump Jun 14, 2024
a73d503
Merge branch 'byteball:master' into master
Taump Jun 20, 2024
c83e5c0
Merge branch 'byteball:master' into master
Taump Jun 24, 2024
9a24777
Merge branch 'byteball:master' into master
Taump Jun 24, 2024
234bf46
Merge branch 'byteball:master' into master
Taump Jul 2, 2024
de71a20
Merge branch 'byteball:master' into master
Taump Aug 29, 2024
b5648ed
fix(Modal & Drawer): rename visible->open
Taump Aug 29, 2024
19619ea
feat: add venue information to MarketPage
Taump Aug 29, 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
2 changes: 1 addition & 1 deletion src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const Header = () => {
</Col>
</> : <>
<Button onClick={changeVisible} size="large">{t("header.menu", "Menu")}</Button>
<Drawer width={width >= 320 ? 320 : width} visible={showMenu} onClose={changeVisible} bodyStyle={{ width: '100%', textAlign: 'center', display: 'flex', flexDirection: 'column', maxHeight: 'calc(100vh - 50px)' }}>
<Drawer width={width >= 320 ? 320 : width} open={showMenu} onClose={changeVisible} bodyStyle={{ width: '100%', textAlign: 'center', display: 'flex', flexDirection: 'column', maxHeight: 'calc(100vh - 50px)' }}>
<div className={styles.mainMenuWrap}>
<MainMenu direction="vertical" onClose={changeVisible} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/modals/AddLiquidityModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const AddLiquidityModal = ({ disabled, yes_team, no_team }) => {
width={width > 640 ? 640 : width}
placement="right"
size="large"
visible={visible}
open={visible}
onClose={close}
>

Expand Down
2 changes: 1 addition & 1 deletion src/modals/ClaimProfitModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const ClaimProfitModal = ({ disabled, yes_team, no_team }) => {
width={width > 640 ? 640 : width}
placement="right"
size="large"
visible={visible}
open={visible}
onClose={close}
>
<Title level={2}>{t("modals.claim_profit.title", "Claim profit")}</Title>
Expand Down
2 changes: 1 addition & 1 deletion src/modals/CreateNowModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const CreateNowModal = (props) => {
placement="right"
size="large"
key={`${props.feed_name} ${props.event_date} ${props.expect_datafeed_value}`}
visible={visible}
open={visible}
onClose={close}
autoFocus={true}
destroyOnClose={true}
Expand Down
2 changes: 1 addition & 1 deletion src/modals/TradeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const TradeModal = memo(({ disabled, visible, setVisible, yes_team, no_te
width={width > 640 ? 640 : width}
placement="right"
size="large"
visible={visible}
open={visible}
onClose={close}
>

Expand Down
2 changes: 1 addition & 1 deletion src/modals/ViewParamsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ViewParamsModal = ({ reserve_asset, allow_draw, oracle, feed_name,
width={width > 640 ? 640 : width}
placement="right"
size="large"
visible={visible}
open={visible}
onClose={close}
>
<Title level={2} style={{ marginBottom: 0 }}>{t("modals.view_params.title", "View params")}</Title>
Expand Down
2 changes: 1 addition & 1 deletion src/modals/WalletModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const WalletModal = ({ children = "WALLET", type = "default", styles = {}
<Button onClick={changeVisible} size="large" type={type} style={btnStyles}>{currentWalletAddress ? `${currentWalletAddress.slice(0, 7)}...` : (children === "WALLET" ? t("modals.wallet.title", "Wallet") : children)}</Button>

<Modal
visible={visible}
open={visible}
onCancel={changeVisible}
footer={null}
>
Expand Down
11 changes: 10 additions & 1 deletion src/pages/MarketPage/MarketPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
selectActiveMarketParams,
selectActiveMarketStateVars,
selectActiveMarketStatus,
selectActiveTeams
selectActiveTeams,
selectActiveVenue
} from "store/slices/activeSlice";
import { setActiveMarket } from "store/thunks/setActiveMarket";
import { selectLanguage, selectPriceOrOdds, selectReserveAssets, selectReservesRate } from "store/slices/settingsSlice";
Expand Down Expand Up @@ -123,6 +124,8 @@ export const MarketPage = () => {
const reserveAssets = useSelector(selectReserveAssets);
const stateVars = useSelector(selectActiveMarketStateVars);

const venue = useSelector(selectActiveVenue);

const candles = useSelector(selectActiveDailyCandles);
const datafeedValue = useSelector(selectActiveDatafeedValue);

Expand Down Expand Up @@ -400,6 +403,12 @@ export const MarketPage = () => {
</Row>
</div>}

{venue ? <Row className={styles.venueWrap}>
<Col span={24} className={styles.venueCol}>
<span>{venue}</span>
</Col>
</Row> : null}

<Row justify="space-between" align="middle">
<Space size='large' wrap={true} style={{ marginBottom: 20, marginTop: 10 }}>
<TradeModal
Expand Down
8 changes: 8 additions & 0 deletions src/pages/MarketPage/MarketPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@
min-height: 120px;
}

.venueWrap {
margin-bottom: 14px;
}

.venueCol {
text-align: center;
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
.vs {
Expand Down
5 changes: 5 additions & 0 deletions src/services/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class Backend {
const crest = await this.axios.get(`/crest/${sport}/${competition}/${team_id}`);
return crest?.data;
}

getVenue = async (feed_name) => {
const venueRes = await this.axios.get(`/venue/${feed_name}`);
return venueRes?.data;
}
}

export default new Backend();
6 changes: 4 additions & 2 deletions src/store/slices/activeSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const activeSlice = createSlice({
},
extraReducers: (builder) => {
builder.addCase(setActiveMarket.fulfilled, (state, action) => {
const { params, stateVars, recentEvents, recentEventsCount, dailyCandles, datafeedValue, yesTeam, noTeam, currencyCandles, currencyCurrentValue, league, created_at, committed_at, base_aa, first_trade_ts, yes_odds, no_odds, draw_odds, yes_crest_url, no_crest_url } = action.payload;
const { params, stateVars, recentEvents, recentEventsCount, dailyCandles, datafeedValue, yesTeam, noTeam, currencyCandles, currencyCurrentValue, league, created_at, committed_at, base_aa, first_trade_ts, yes_odds, no_odds, draw_odds, yes_crest_url, no_crest_url, venue = null } = action.payload;

state.params = { ...params, ...league, created_at, committed_at, first_trade_ts, base_aa, yes_odds, no_odds, draw_odds, yes_crest_url, no_crest_url };
state.stateVars = stateVars;
Expand All @@ -55,7 +55,8 @@ export const activeSlice = createSlice({
state.currencyCandles = currencyCandles || [];
state.currencyCurrentValue = currencyCurrentValue || 0;
state.teams = { yes: yesTeam || null, no: noTeam || null };

state.venue = venue;

state.status = 'loaded';
});

Expand Down Expand Up @@ -104,5 +105,6 @@ export const selectActiveRecentEventsCount = state => state.active.recentEventsC
export const selectActiveDailyCandles = state => state.active.dailyCandles;
export const selectActiveDatafeedValue = state => state.active.datafeedValue;
export const selectActiveTeams = state => state.active.teams;
export const selectActiveVenue = state => state.active.venue;
export const selectActiveCurrencyCandles = state => state.active.currencyCandles;
export const selectActiveCurrencyCurrentValue = state => state.active.currencyCurrentValue;
10 changes: 9 additions & 1 deletion src/store/thunks/setActiveMarket.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const setActiveMarket = createAsyncThunk(
let currencyCurrentValue = 0;
let league_emblem = null;
let league = null;
let venue = null;

let yes_odds = null;
let no_odds = null;
Expand Down Expand Up @@ -115,8 +116,14 @@ export const setActiveMarket = createAsyncThunk(
}

const [championship, yes_abbreviation, no_abbreviation] = params.feed_name.split("_");
const championships = await backend.getChampionships();

const [venueData, championships] = await Promise.all([
backend.getVenue(params.feed_name).then(data => data?.data).catch(() => null),
backend.getChampionships()
]);

venue = venueData;

const sport = Object.entries(championships).find(([_, cs]) => cs.find(({ code }) => code === championship));

if (sport) {
Expand Down Expand Up @@ -183,6 +190,7 @@ export const setActiveMarket = createAsyncThunk(

return {
params,
venue,
stateVars,
base_aa,
dailyCandles,
Expand Down