Skip to content

Commit

Permalink
Merge branch 'main' into update-navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
nguvictor authored Oct 5, 2023
2 parents a86ecfc + a3bcf6b commit 10fedbc
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 252 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ next-env.d.ts
/test-results/
/playwright-report/
/playwright/.cache/

localhost:3000/
10 changes: 8 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

logs/*
playwright-report/*
/logs/
.swc/
/test-results/
/playwright-report/
/playwright/.cache/

localhost:3000/

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Check out [existing issues (especially Todo)](https://github.com/orgs/DeXter-on-

Here are a few guidelines to follow:

- **Discuss** major changes with the maintainers before starting work, our [Discord](https://discord.gg/YCtv3BDQ) is a good place to do that
- **Discuss** major changes with the maintainers before starting work, our [Discord](https://discord.gg/Y44jqe2q2W) is a good place to do that
- **Use [Pull Requests (PRs)](https://docs.github.com/en/pull-requests)** - commits direclty to `main` branch are not allowed
- **Use [Prettier](https://prettier.io/)** and automatic code formatting to keep PRs focused on the changes
- **Use [ESLint](https://eslint.org/)** to keep code clean and consistent
Expand Down
106 changes: 44 additions & 62 deletions src/app/components/AccountHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,86 +1,68 @@
import React, { useEffect, useCallback } from "react";
import { useAppDispatch, useAppSelector } from "../hooks";
import React, { useEffect } from "react";
import { useAppDispatch, useAppSelector } from "hooks";
import {
fetchAccountHistory,
Tables,
fetchAccountHistory,
selectOpenOrders,
setSelectedTable,
selectTables,
} from "../redux/accountHistorySlice";
} from "redux/accountHistorySlice";
import { DisplayTable } from "./DisplayTable";

interface ButtonProps {
label: string;
value: Tables;
selectedValue: Tables;
onClick: (value: Tables) => void;
}
function OrdersTabs() {
const dispatch = useAppDispatch();
const { selectedTable, tables } = useAppSelector(
(state) => state.accountHistory
);
const openOrders = useAppSelector(selectOpenOrders);

function tabClass(isActive: boolean) {
return (
"tab w-max no-underline h-full py-3 tab-border-1 uppercase" +
(isActive
? " tab-active tab-bordered text-accent-focus !border-accent"
: "")
);
}

const Button: React.FC<ButtonProps> = ({
label,
value,
selectedValue,
onClick,
}) => (
<button
onClick={() => onClick(value)}
aria-label={label}
className={"btn" + (selectedValue === value ? " btn-active" : "")}
>
{label}
</button>
);
return (
<div className="m-4">
<div className="tabs min-w-fit flex flex-nowrap space-x-4">
{tables.map((tableName) => (
<div
key={tableName}
className={tabClass(selectedTable === tableName)}
onClick={() => dispatch(setSelectedTable(tableName))}
>
{tableName}{" "}
{tableName === Tables.OPEN_ORDERS && openOrders.length ? (
<span className="badge badge-xs font-bold badge-accent ml-2 p-0.5 rounded-none">
{openOrders.length}
</span>
) : null}
</div>
))}
</div>
</div>
);
}

export function AccountHistory() {
const dispatch = useAppDispatch();
const account = useAppSelector(
(state) => state.radix?.walletData.accounts[0]?.address
);
const pairAddress = useAppSelector((state) => state.pairSelector.address);
const selectedTable = useAppSelector(
(state) => state.accountHistory.selectedTable
);
const tables = useAppSelector(selectTables);

useEffect(() => {
dispatch(fetchAccountHistory());
}, [dispatch, account, pairAddress]);

const handleButtonClick = useCallback(
(table: Tables) => {
dispatch(setSelectedTable(table));
},
[dispatch]
);

return (
<div>
<div className="btn-group">
{tables.map((table) => (
<Button
key={table}
label={table}
value={table}
selectedValue={selectedTable}
onClick={handleButtonClick}
/>
))}
{/* //---COMMENTED OUT BUTTONS FOR SHOW ALL ORDERS AND EXPORT
//TO NOT CONFUSE THE TESTERS----------------------------- */}
{/* <button
<button
className="btn btn-ghost normal-case text-xl"
aria-label="Show all orders"
>
Show all orders
</button>
className="btn btn-ghost normal-case text-xl"
aria-label="Export as CSV"
>
Export as CSV
</button> */}
<OrdersTabs />
<div className="">
<DisplayTable />
</div>
<DisplayTable />
</div>
);
}
Loading

0 comments on commit 10fedbc

Please sign in to comment.