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

Aum / GRWT-5056 /product-types-list #68

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ce595f5
feat: created product service for getting products types
aum-deriv Mar 4, 2025
4752040
styles: basic UI changed
aum-deriv Mar 4, 2025
5554ad4
feat: added the TradeTypeList and TradeTypesListController
aum-deriv Mar 4, 2025
d5945f8
chore: remove unused imports
aum-deriv Mar 4, 2025
84f499d
styles: restructure TradePage to position TradeTypesListController
aum-deriv Mar 4, 2025
1457436
refactor: use TabList for TradeTypesListController + minor UI changes
aum-deriv Mar 5, 2025
af061fe
styles: some UI changes for Header and MainLayout
aum-deriv Mar 5, 2025
105e96a
feat: more UI changes for the AccountSwitcher
aum-deriv Mar 5, 2025
baf9bca
fix: responsive UI and unit tests
aum-deriv Mar 5, 2025
f3a2230
fix: responsive UI and unit tests
aum-deriv Mar 5, 2025
fbc7910
Merge branch 'aum/product-types-list' of github.com:aum-deriv/champio…
aum-deriv Mar 5, 2025
1f2d968
fix: apply suggestions from devloai
aum-deriv Mar 5, 2025
2c75fd1
fix: test after changes to HowToTrade and GuideModal
aum-deriv Mar 5, 2025
f9eefed
feat: added Skeleton component to show for loaders
aum-deriv Mar 6, 2025
c7fd936
chore: added README docs
aum-deriv Mar 6, 2025
e67b7e4
feat: added tradeTypeDisplayName to tradeStore for reusability
aum-deriv Mar 6, 2025
345eadd
Merge branch 'master' of https://github.com/deriv-com/champion-trader…
aum-deriv Mar 7, 2025
16c3805
chore: apply AI reviewer suggestions
aum-deriv Mar 7, 2025
703ab21
fix: TradePage unit tests
aum-deriv Mar 7, 2025
e12d3e8
Merge branch 'master' of https://github.com/deriv-com/champion-trader…
aum-deriv Mar 10, 2025
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
Binary file modified public/favicon.ico
Binary file not shown.
Binary file removed public/logo.png
Binary file not shown.
12 changes: 12 additions & 0 deletions public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 65 additions & 63 deletions rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,73 @@ import path from "path";
dotenv.config();

export default defineConfig({
plugins: [pluginReact(), pluginBasicSsl()],
html: {
template: "./index.html",
title: "Champion Trader",
favicon: "public/favicon.ico",
},
source: {
define: {
"process.env.RSBUILD_WS_URL": JSON.stringify(process.env.RSBUILD_WS_URL),
"process.env.RSBUILD_WS_PUBLIC_PATH": JSON.stringify(
process.env.RSBUILD_WS_PUBLIC_PATH
),
"process.env.RSBUILD_WS_PROTECTED_PATH": JSON.stringify(
process.env.RSBUILD_WS_PROTECTED_PATH
),
"process.env.RSBUILD_REST_URL": JSON.stringify(
process.env.RSBUILD_REST_URL
),
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.RSBUILD_SSE_PUBLIC_PATH": JSON.stringify(
process.env.RSBUILD_SSE_PUBLIC_PATH
),
"process.env.RSBUILD_SSE_PROTECTED_PATH": JSON.stringify(
process.env.RSBUILD_SSE_PROTECTED_PATH
),
plugins: [pluginReact(), pluginBasicSsl()],
html: {
template: "./index.html",
title: "Champion Trader",
favicon: "public/favicon.ico",
},
alias: {
"@": "./src",
source: {
define: {
"process.env.RSBUILD_WS_URL": JSON.stringify(
process.env.RSBUILD_WS_URL
),
"process.env.RSBUILD_WS_PUBLIC_PATH": JSON.stringify(
process.env.RSBUILD_WS_PUBLIC_PATH
),
"process.env.RSBUILD_WS_PROTECTED_PATH": JSON.stringify(
process.env.RSBUILD_WS_PROTECTED_PATH
),
"process.env.RSBUILD_REST_URL": JSON.stringify(
process.env.RSBUILD_REST_URL
),
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.RSBUILD_SSE_PUBLIC_PATH": JSON.stringify(
process.env.RSBUILD_SSE_PUBLIC_PATH
),
"process.env.RSBUILD_SSE_PROTECTED_PATH": JSON.stringify(
process.env.RSBUILD_SSE_PROTECTED_PATH
),
},
alias: {
"@": "./src",
},
},
},
server: {
port: 4113,
host: "localhost",
strictPort: true,
},
output: {
copy: [
{
from: path.resolve(
__dirname,
"node_modules/@deriv-com/smartcharts-champion/dist"
),
to: "js/smartcharts/",
globOptions: {
ignore: ["**/*.LICENSE.txt"]
}
},
{
from: path.resolve(
__dirname,
"node_modules/@deriv-com/smartcharts-champion/dist/chart/assets"
),
to: "assets",
},
],
filename: {
js: "[name].[hash:8].js",
css: "[name].[hash:8].css",
assets: "assets/[name].[hash:8][ext]"
server: {
port: 4113,
host: "localhost",
strictPort: true,
},
distPath: {
js: "js",
css: "css",
html: ""
output: {
copy: [
{
from: path.resolve(
__dirname,
"node_modules/@deriv-com/smartcharts-champion/dist"
),
to: "js/smartcharts/",
globOptions: {
ignore: ["**/*.LICENSE.txt"],
},
},
{
from: path.resolve(
__dirname,
"node_modules/@deriv-com/smartcharts-champion/dist/chart/assets"
),
to: "assets",
},
],
filename: {
js: "[name].[hash:8].js",
css: "[name].[hash:8].css",
assets: "assets/[name].[hash:8][ext]",
},
distPath: {
js: "js",
css: "css",
html: "",
},
cleanDistPath: true,
},
cleanDistPath: true
},
});
6 changes: 2 additions & 4 deletions src/components/AccountSwitcher/AccountSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export const AccountSwitcher: React.FC = () => {
<AccountPopoverTrigger asChild>
<button
data-testid="balance-display"
className={`flex flex-col relative ${
isLandscape ? "items-end" : "items-start"
}`}
className="flex flex-col relative"
>
<div className="flex items-center gap-1">
<span
Expand Down Expand Up @@ -53,7 +51,7 @@ export const AccountSwitcher: React.FC = () => {
/>
)}
</div>
<span className="text-sm font-semibold align-start">
<span className="text-base font-semibold align-start">
{selectedAccount?.isDemo ? "10,000" : balance}{" "}
{selectedAccount?.currency || "USD"}
</span>
Expand Down
32 changes: 22 additions & 10 deletions src/components/Duration/DurationController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ interface DurationControllerProps {
onClose?: () => void;
}

export const DurationController: React.FC<DurationControllerProps> = ({ onClose }) => {
export const DurationController: React.FC<DurationControllerProps> = ({
onClose,
}) => {
const { duration, setDuration } = useTradeStore();
const { isLandscape } = useOrientationStore();
const { setBottomSheet } = useBottomSheetStore();
Expand All @@ -43,7 +45,8 @@ export const DurationController: React.FC<DurationControllerProps> = ({ onClose
const [localDuration, setLocalDuration] = React.useState(duration);
const [value, type] = localDuration.split(" ");
const selectedType = type as DurationType;
const selectedValue: string | number = type === "hour" ? value : parseInt(value, 10);
const selectedValue: string | number =
type === "hour" ? value : parseInt(value, 10);

// Use debounced updates for desktop scroll
useDebounce(
Expand All @@ -57,7 +60,10 @@ export const DurationController: React.FC<DurationControllerProps> = ({ onClose
);

const handleTypeSelect = (type: DurationType) => {
const newDuration = type === "hour" ? "1:0 hour" : `${getDurationValues(type)[0]} ${type}`;
const newDuration =
type === "hour"
? "1:0 hour"
: `${getDurationValues(type)[0]} ${type}`;
setLocalDuration(newDuration);
};

Expand Down Expand Up @@ -88,13 +94,19 @@ export const DurationController: React.FC<DurationControllerProps> = ({ onClose
<>
<div className={isLandscape ? "flex" : ""}>
{!isLandscape && <BottomSheetHeader title="Duration" />}
<TabList
tabs={DURATION_TYPES}
selectedValue={selectedType}
onSelect={handleTypeSelect as (value: string) => void}
variant={isLandscape ? "vertical" : "chip"}
/>
<div className={`flex-1 relative bg-white ${isLandscape ? "px-2" : "px-8"}`}>
<div className="mx-4">
<TabList
tabs={DURATION_TYPES}
selectedValue={selectedType}
onSelect={handleTypeSelect as (value: string) => void}
variant={isLandscape ? "vertical" : "chip"}
/>
</div>
<div
className={`flex-1 relative bg-white ${
isLandscape ? "px-2" : "px-8"
}`}
>
{selectedType === "hour" ? (
<HoursDurationValue
selectedValue={selectedValue.toString()}
Expand Down
13 changes: 9 additions & 4 deletions src/components/HowToTrade/GuideModal.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { Modal } from "@/components/ui/modal";
import { guideConfig } from "@/config/guideConfig";
import { TabList } from "../ui/tab-list";
import { TradeType } from "@/config/tradeTypes";

interface GuideProps {
isOpen: boolean;
onClose: () => void;
type?: string;
type?: TradeType;
}

const Guides = [{ label: "Rise/Fall", value: "rise-fall" }];
const Guides = [{ label: "Rise/Fall", value: "rise_fall" }];

export const GuideModal = ({ isOpen, onClose, type = "rise-fall" }: GuideProps) => {
export const GuideModal = ({
isOpen,
onClose,
type = "rise_fall",
}: GuideProps) => {
const content = guideConfig[type]?.body;

if (!content) {
Expand All @@ -26,7 +31,7 @@ export const GuideModal = ({ isOpen, onClose, type = "rise-fall" }: GuideProps)
<TabList
variant={"chip"}
tabs={Guides}
selectedValue={"rise-fall"}
selectedValue={"rise_fall"}
onSelect={(value) => value}
/>
}
Expand Down
7 changes: 5 additions & 2 deletions src/components/HowToTrade/HowToTrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { useBottomSheetStore } from "@/stores/bottomSheetStore";
import { useDeviceDetection } from "@/hooks/useDeviceDetection";
import { GuideModal } from "./GuideModal";
import { ChevronRight } from "lucide-react";
import { useTradeStore } from "@/stores/tradeStore";

export const HowToTrade: React.FC = () => {
const { setBottomSheet } = useBottomSheetStore();
const { isDesktop } = useDeviceDetection();
const [isModalOpen, setIsModalOpen] = useState(false);
const { tradeTypeDisplayName } = useTradeStore();

const handleClick = () => {
if (isDesktop) {
Expand All @@ -27,15 +29,16 @@ export const HowToTrade: React.FC = () => {
onClick={handleClick}
className="text-gray-500 hover:text-gray-600 text-sm flex items-center gap-1"
>
How to trade Rise/Fall?
How to trade {tradeTypeDisplayName}
?
<ChevronRight className="w-4 h-4" />
</button>

{isDesktop && (
<GuideModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
type="rise-fall"
type="rise_fall"
/>
)}
</>
Expand Down
4 changes: 4 additions & 0 deletions src/components/HowToTrade/__tests__/HowToTrade.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jest.mock("@/stores/bottomSheetStore", () => ({
}),
}));

jest.mock("@/stores/tradeStore", () => ({
useTradeStore: jest.fn(() => ({ tradeTypeDisplayName: "Rise/Fall" })),
}));

describe("HowToTrade", () => {
beforeEach(() => {
mockSetBottomSheet.mockClear();
Expand Down
8 changes: 5 additions & 3 deletions src/components/MarketInfo/MarketInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export const MarketInfo: React.FC<MarketInfoProps> = ({
if (isMobile) {
return (
<div
className="inline-flex cursor-pointer mx-4 mt-3"
className="inline-flex cursor-pointer mx-4 lg:mt-3"
data-id="market-info"
onClick={onClick}
>
<div className="flex items-center gap-4 px-4 py-3 bg-black/[0.04] rounded-lg">
<div
className="flex items-center gap-4 px-4 py-3 bg-black/[0.04] rounded-lg"
onClick={onClick}
>
{selectedMarket && (
<div className="w-8 h-8 flex items-center justify-center">
<MarketIcon
Expand Down
Loading