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

Prince/Purchase section refactor #800

Merged
merged 44 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f4f44f0
chore: refactored camelCase to snake_case
prince-deriv Aug 14, 2024
796db43
chore: other refactor
prince-deriv Aug 14, 2024
b49ca43
chore: other refactor
prince-deriv Aug 14, 2024
06bd5af
chore: other refactor
prince-deriv Aug 14, 2024
b827f44
chore: other refactor
prince-deriv Aug 14, 2024
bfbdf19
chore: other refactor
prince-deriv Aug 14, 2024
4528ded
chore: other refactor
prince-deriv Aug 14, 2024
f3ef0f4
chore: other refactor
prince-deriv Aug 14, 2024
36bed37
chore: other refactor
prince-deriv Aug 14, 2024
36ebae1
chore: other refactor
prince-deriv Aug 14, 2024
3a0bd1d
chore: other refactor
prince-deriv Aug 14, 2024
b59f0d7
chore: other refactor
prince-deriv Aug 14, 2024
c21dbe5
chore: other refactor
prince-deriv Aug 14, 2024
5708fc8
chore: other refactor
prince-deriv Aug 14, 2024
3f12be1
chore: other refactor
prince-deriv Aug 14, 2024
b2cd7eb
chore: other refactor
prince-deriv Aug 14, 2024
a9aec06
chore: other refactor
prince-deriv Aug 14, 2024
f45d978
chore: other refactor
prince-deriv Aug 14, 2024
2363ba4
chore: other refactor
prince-deriv Aug 14, 2024
ec718ed
chore: other refactor
prince-deriv Aug 14, 2024
d31a043
chore: other refactor
prince-deriv Aug 14, 2024
1b3befe
chore: other refactor
prince-deriv Aug 14, 2024
a0b8bb3
chore: other refactor
prince-deriv Aug 14, 2024
4ab26c3
chore: other refactor
prince-deriv Aug 14, 2024
439edfa
chore: other refactor
prince-deriv Aug 14, 2024
571658c
chore: other refactor
prince-deriv Aug 14, 2024
4f2c95b
chore: other refactor
prince-deriv Aug 15, 2024
4cf59cd
chore: other refactor
prince-deriv Aug 15, 2024
d71b00a
chore: other refactor
prince-deriv Aug 15, 2024
920f6d3
chore: other refactor
prince-deriv Aug 15, 2024
b29928a
chore: other refactor
prince-deriv Aug 15, 2024
a99964f
Merge branch 'master' into refactor-attempt2
prince-deriv Aug 15, 2024
71dba71
Merge branch 'master' into refactor-attempt2
prince-deriv Aug 16, 2024
1ecfa47
chore: refactor fix
prince-deriv Aug 16, 2024
db743c7
chore: refactor fix
prince-deriv Aug 16, 2024
64772d7
chore: refactor fix
prince-deriv Aug 16, 2024
99349c6
chore: refactor fix
prince-deriv Aug 16, 2024
8bb4052
chore: refactor fix
prince-deriv Aug 16, 2024
b588702
chore: refactor fix
prince-deriv Aug 16, 2024
f10908e
chore: refactor fix
prince-deriv Aug 16, 2024
5e17164
chore: refactor fix
prince-deriv Aug 16, 2024
06d20bd
chore: refactor fix
prince-deriv Aug 16, 2024
7dbcb76
chore: text default size is md
prince-deriv Aug 19, 2024
5e8bf41
Merge branch 'master' into refactor-attempt2
prince-deriv Aug 19, 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/javascript/app/components/loading-spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const show = (content_id) => {
*/
export const hide = (content_id) => {
dataManager.setContract({
hidePageLoader: true,
hide_page_loader: true,
});

assertContainerExists(content_id);
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/app/pages/bottom/data/explanation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { localize } from '../../../../_common/localize.js';

export const contractExplanationData = {
export const contract_explanation_data = {
winning: {
asian: {

Expand Down
42 changes: 21 additions & 21 deletions src/javascript/app/pages/bottom/explanation.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import parse from 'html-react-parser';
import { SectionMessage, Skeleton, Text } from '@deriv-com/quill-ui';
import { contractExplanationData } from './data/explanation.js';
import { contract_explanation_data } from './data/explanation.js';
import Language from '../../../_common/language';
import Url from '../../../_common/url';
import { localize } from '../../../_common/localize.js';
Expand All @@ -10,9 +10,9 @@ import { useContractChange } from '../../hooks/events.js';

export const Explanation = ({ explanationOnly = false }) => {
prince-deriv marked this conversation as resolved.
Show resolved Hide resolved

const [formName,setFormName] = useState(null);
const [form_name,setFormName] = useState(null);
prince-deriv marked this conversation as resolved.
Show resolved Hide resolved

const hasContractChanges = useContractChange();
const has_contract_changes = useContractChange();

useEffect(() => {
const actualFormName = dataManager.getContract('explanationFormName');
prince-deriv marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -22,7 +22,7 @@ export const Explanation = ({ explanationOnly = false }) => {
setFormName(actualFormName);
}, 500);

}, [hasContractChanges]);
}, [has_contract_changes]);

const language = Language.get();
const image_path = Url.urlForStatic(
Expand All @@ -31,7 +31,7 @@ export const Explanation = ({ explanationOnly = false }) => {
const Notes = () => (
<>
<strong>{localize('Note')}: </strong>
{contractExplanationData.note[formName].content.map((data, idx) => (
{contract_explanation_data.note[form_name].content.map((data, idx) => (
<span key={idx}>{parse(data)}</span>
))}
</>
Expand Down Expand Up @@ -93,19 +93,19 @@ export const Explanation = ({ explanationOnly = false }) => {
},
};

if (formName) {
if (form_name) {
return (
<div className='tab-explanation'>
{/* ========== Winning ========== */}
{!explanationOnly && (
<>
<div id='explanation_winning'>
<div id={`winning_${formName}`}>
<div id={`winning_${form_name}`}>
<div className='explanation-heading'>
<Text size='lg' bold >{localize('Winning the contract')}</Text>
<Text size='lg' bold>{localize('Winning the contract')}</Text>
</div>
<div className='explanation-content'>
{contractExplanationData.winning[formName].content.map(
{contract_explanation_data.winning[form_name].content.map(
(data, idx) => (
<Text size='md' key={idx}>{parse(data)}</Text>
)
Expand All @@ -116,7 +116,7 @@ export const Explanation = ({ explanationOnly = false }) => {
</div>

{/* ========== Image ========== */}
{images[formName] && (
{images[form_name] && (
<div id='explanation_image'>
<div className='gr-row'>
<div className='gr-2 hide-mobile' />
Expand All @@ -127,15 +127,15 @@ export const Explanation = ({ explanationOnly = false }) => {
<img
id='explanation_image_1'
className='responsive'
src={`${image_path}${images[formName].image1}?${process.env.BUILD_HASH}`}
src={`${image_path}${images[form_name].image1}?${process.env.BUILD_HASH}`}
/>
</div>
{images[formName].image2 && (
{images[form_name].image2 && (
<div className='gr-4 gr-12-m padding-left'>
<img
id='explanation_image_2'
className='responsive'
src={`${image_path}${images[formName].image2}?${process.env.BUILD_HASH}`}
src={`${image_path}${images[form_name].image2}?${process.env.BUILD_HASH}`}
/>
</div>
)}
Expand All @@ -149,29 +149,29 @@ export const Explanation = ({ explanationOnly = false }) => {

{/* ========== Explain ========== */}
<div id='explanation_explain' className='gr-child'>
<div id={`explain_${formName}`} >
<div id={`explain_${form_name}`} >
<div className='explanation-heading'>
<Text size='lg' bold >{contractExplanationData.explain[formName].title}</Text>
<Text size='lg' bold >{contract_explanation_data.explain[form_name].title}</Text>
</div>
<div className='explanation-content'>
{contractExplanationData.explain[formName].content.map(
{contract_explanation_data.explain[form_name].content.map(
(data, idx) => (
<Text size='md' key={idx}>{parse(data)}</Text>
)
)}
</div>

{contractExplanationData.explain[formName].title_secondary && (
{contract_explanation_data.explain[form_name].title_secondary && (
<div className='explanation-heading secondary-heading'>
<Text size='lg' bold>
{contractExplanationData.explain[formName].title_secondary}
{contract_explanation_data.explain[form_name].title_secondary}
</Text>
</div>
)}

{contractExplanationData.explain[formName].content_secondary && (
{contract_explanation_data.explain[form_name].content_secondary && (
<div className='explanation-content'>
{contractExplanationData.explain[formName].content_secondary.map(
{contract_explanation_data.explain[form_name].content_secondary.map(
(data, idx) => (
<Text size='md' key={idx}>{parse(data)}</Text>
)
Expand All @@ -184,7 +184,7 @@ export const Explanation = ({ explanationOnly = false }) => {

{/* ========== Note ========== */}
{!explanationOnly && (
contractExplanationData.note[formName] && (
contract_explanation_data.note[form_name] && (
<SectionMessage status='info' message={<Notes />} size='sm' />
)
)}
Expand Down
58 changes: 29 additions & 29 deletions src/javascript/app/pages/bottom/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import dataManager from '../../common/data_manager.js';
import LastDigit from '../trade/last_digit.jsx';

const BottomTabs = () => {
const hasMarketChange = useMarketChange();
const [selectedTab, setSelectedTab] = useState(1);
const [hasLastDigit, setHasLastDigit] = useState(false);
const [formName, setFormName] = useState('');
const hasContractChange = useContractChange();
const savedTab = sessionStorage.getItem('currentTab');
const triggerOldTabTimer = useRef();
const [isShowGraph, setIsShowGraph] = useState(false);
const has_market_change = useMarketChange();
const [selected_tab, setSelectedTab] = useState(1);
const [has_last_digit, setHasLastDigit] = useState(false);
const [form_name, setFormName] = useState('');
const has_contract_change = useContractChange();
const saved_tab = sessionStorage.getItem('currentTab');
const [is_show_graph, setIsShowGraph] = useState(false);
const trigger_old_tab_timer = useRef();

const handleChange = (e) => {
setSelectedTab(e);
Expand All @@ -31,43 +31,43 @@ const BottomTabs = () => {

const tabs = [{ label: localize('Chart') }, { label: localize('Explanation') }];

const bottomTabOptions = hasLastDigit
const bottom_tab_options = has_last_digit
? [...tabs, { label: localize('Last Digit Stats') }]
: tabs;

useEffect(() => {
setFormName(dataManager.getContract('explanationFormName'));
}, [hasContractChange, hasMarketChange]);
}, [has_contract_change, has_market_change]);

useEffect(() => {
setHasLastDigit(formName === 'digits' || formName === 'evenodd' || formName === 'overunder');
}, [formName]);
setHasLastDigit(form_name === 'digits' || form_name === 'evenodd' || form_name === 'overunder');
}, [form_name]);

useEffect(() => {
if (savedTab !== null) {
const tabIndex = parseInt(savedTab);
if (tabIndex === 2 && !hasLastDigit) {
if (saved_tab !== null) {
const tab_index = parseInt(saved_tab);
if (tab_index === 2 && !has_last_digit) {
setSelectedTab(1);
} else {
setSelectedTab(tabIndex);
setSelectedTab(tab_index);
}
} else {
setSelectedTab(1);
}
}, [hasLastDigit]);
}, [has_last_digit]);

useEffect(() => {
const oppositeTab = (selectedTab + 1) > 2 ? 0 : (selectedTab + 1);
const opposite_tab = (selected_tab + 1) > 2 ? 0 : (selected_tab + 1);

triggerOldTab(oppositeTab);
triggerOldTab(opposite_tab);

triggerOldTabTimer.current = setTimeout(() => {
triggerOldTab(selectedTab);
trigger_old_tab_timer.current = setTimeout(() => {
triggerOldTab(selected_tab);
}, 100);
}, [selectedTab, savedTab]);
}, [selected_tab, saved_tab]);

useEffect(() => () => {
clearTimeout(triggerOldTabTimer.current);
clearTimeout(trigger_old_tab_timer.current);
WebtraderChart.cleanupChart();
WebtraderChart.showChart();
},[]);
Expand All @@ -76,20 +76,20 @@ const BottomTabs = () => {
<>
<div className='quill-container-centered'>
<SegmentedControlSingleChoice
options={bottomTabOptions}
selectedItemIndex={selectedTab}
options={bottom_tab_options}
selectedItemIndex={selected_tab}
onChange={handleChange}
/>
</div>
<div className='bottom-content-section'>
{selectedTab === 0 && <Graph
{selected_tab === 0 && <Graph
onUnload={() => setIsShowGraph(false)}
onLoad={() => setIsShowGraph(true)}
/>}
{selectedTab === 1 && <Explanation />}
{selectedTab === 2 && hasLastDigit && <LastDigit />}
{selected_tab === 1 && <Explanation />}
{selected_tab === 2 && has_last_digit && <LastDigit />}

<div id='tab_graph' className={`chart-section ${isShowGraph ? '' : 'grap-hide'}`}>
<div id='tab_graph' className={`chart-section ${is_show_graph ? '' : 'grap-hide'}`}>
<p className='error-msg' id='chart-error' />
<div id='trade_live_chart'>
<div id='webtrader_chart' />
Expand Down
4 changes: 2 additions & 2 deletions src/javascript/app/pages/form/barrier-fields.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const BarrierFields = ({ form_name, handleAmountChange }) => {
const barrier_low = Defaults.get(PARAM_NAMES.BARRIER_LOW);

useEffect(() => {
setBarrierData((oldData) => ({
...oldData,
setBarrierData((old_data) => ({
...old_data,
...dataManager.getAllTrades(),
}));
}, [hasBarrierChange]);
prince-deriv marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading
Loading