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

Remove spinner on homepage. #2

Open
wants to merge 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
b06d338
Remove spinner on homepage.
milesthedisch Feb 28, 2022
decfb35
Dangerous shit
milesthedisch Mar 1, 2022
5d5ff41
Revert dangerous
milesthedisch Mar 1, 2022
0d6b12e
Add debug route
milesthedisch Mar 1, 2022
8c6267c
Deploy trigger
milesthedisch Mar 1, 2022
5ba0e14
Deploy
milesthedisch Mar 1, 2022
9c02b27
Deploy
milesthedisch Mar 1, 2022
1009405
Remove debug route
milesthedisch Mar 1, 2022
bc1ea53
Add refresh interval, Update components for admin to accept data
milesthedisch Mar 9, 2022
4165b8e
Update user table for admin page
milesthedisch Mar 9, 2022
1e5f0ca
Remove console.log
milesthedisch Mar 9, 2022
3848d92
Add roles, Fix Signout button
milesthedisch Mar 13, 2022
a2423f9
Deploy preview
milesthedisch Mar 13, 2022
66bb9cf
Add preview logic to api
milesthedisch Mar 13, 2022
2317ef5
Deploy
milesthedisch Mar 13, 2022
160dc8f
Update preview logic in route, add debug log
milesthedisch Mar 13, 2022
8d778b3
Merge conflits
milesthedisch Mar 15, 2022
b324e7d
Add chart to main web client
milesthedisch Mar 21, 2022
c151a72
Remove spacing, Update isLoading logic in Dashboard, Add prisma schema
milesthedisch Mar 21, 2022
d223fad
Add 401 custom error page, Update index sheets route, Remove console.log
milesthedisch Mar 22, 2022
a91f695
Merge branch 'preview'
milesthedisch Mar 22, 2022
e495c14
Update units
milesthedisch Mar 22, 2022
6102ec4
Create database routes create and index for User, Add prisma schema
milesthedisch Mar 25, 2022
5e12888
Update protectRoute for debuggin
milesthedisch Mar 25, 2022
56aa764
Remove user session from Api route
milesthedisch Mar 25, 2022
f75075d
Bug
milesthedisch Apr 3, 2022
5682d51
Add strategy create and strategy transactions create handler
milesthedisch Apr 14, 2022
6868492
Move db handlers to seperate folder, Add tests, Update handlers to ts
milesthedisch Apr 19, 2022
becac9d
Both test passing
milesthedisch Apr 19, 2022
9daeb8b
Update schema to use amount
milesthedisch Apr 20, 2022
e31f789
Add strategyFrom, Update seed file to include hours in datetime, Add …
milesthedisch Apr 22, 2022
68e9531
Update revalidate on focus SWR [remove], Update strategy form
milesthedisch Apr 29, 2022
ad051ae
Update seed file to have no date in the future, Update strategies for…
milesthedisch Apr 29, 2022
15cdb79
Add create many tx balances api route and db fn
milesthedisch May 1, 2022
bd92803
Get build ready, type fixes
milesthedisch May 1, 2022
7a26073
Add production share api
milesthedisch May 9, 2022
e52e6bb
REMOVE Sheets api, UPDATE Dashboard & Admin, UPDATE Invitation
milesthedisch Jun 14, 2022
a931baf
Update seed file and schema to have correct prodution seed data
milesthedisch Jun 14, 2022
8d9c2fc
Updated Dialog, Update invitation api
milesthedisch Jun 20, 2022
69d2228
Remove vercel json, had google api key file location, no longer needed
milesthedisch Jun 20, 2022
db5f431
Update seed file
milesthedisch Jun 20, 2022
36b01d6
Update userapi, update calcprice api, typescript errors.
milesthedisch Jun 20, 2022
8fe9979
Update DATABASE_URL in schema, Update packagejson to --execute and --…
milesthedisch Jun 24, 2022
e795334
Updated graph UI, and Update auth to logout to login portal.
milesthedisch Jun 27, 2022
581dc80
Update files to typescript, Add live share price form, Update dialog,…
milesthedisch Jun 29, 2022
7cf9088
Updated strategies, Added live share price form, Add toasts, Add crea…
milesthedisch Jun 30, 2022
105a4bc
Update auth0 base url env to tenant base url, custom domains dont cha…
milesthedisch Jun 30, 2022
535a4f4
Add john doe to seed, Update Dialog to use Snackbar
milesthedisch Jun 30, 2022
46c6bd1
Update seed file, Remove getTxs for user index api to many request to db
milesthedisch Jun 30, 2022
7562e10
Disable 2fa buttons
milesthedisch Jun 30, 2022
6fc2863
Add audit accounts main page, Update audit page to have all subaccount
milesthedisch Jul 1, 2022
ff34f1d
Update audit page, Added all trades page for each position
milesthedisch Jul 3, 2022
6057415
Updated auth to redirect to index to decide what page to land on.
milesthedisch Jul 4, 2022
970bb75
Update audit side
milesthedisch Jul 4, 2022
fb8e562
Update roles url
milesthedisch Jul 4, 2022
cdcd75a
Add balance api, Updated audit account with balance and no current po…
milesthedisch Jul 5, 2022
4225719
Updated dialog UI so it doesn't crash when a user doesnt have a balmo…
milesthedisch Jul 5, 2022
15ffbdc
Added total to trades page.
milesthedisch Jul 10, 2022
c13dc5c
Add pnl and summed data for trades.
milesthedisch Jul 11, 2022
7bede6e
Add both PERP funding
milesthedisch Jul 11, 2022
ba64518
Get all positions that are "closed"
milesthedisch Jul 11, 2022
e71ca8c
Link forked branch of ftx-api
milesthedisch Jul 11, 2022
53770bb
UPdate ftx api
milesthedisch Jul 11, 2022
8bf7f96
Add menu audit and fixed sum funding bug
milesthedisch Jul 13, 2022
46595a4
Update spot margin, reverse order
milesthedisch Jul 14, 2022
5a83618
Abstract out paginating long history for EOFY data, Update trades pag…
milesthedisch Jul 15, 2022
248d5a8
Fix bug object hasOwn not available in old node versions
milesthedisch Jul 15, 2022
4af2be7
Update seed file, Add aggregate funding for all subAccounts, Remove f…
milesthedisch Aug 5, 2022
34cc55a
ASd
milesthedisch Aug 5, 2022
8209ad9
Merge remote-tracking branch 'origin/main'
milesthedisch Aug 5, 2022
a73d4d2
Update aggregate pnl
milesthedisch Aug 5, 2022
80cf840
Add padding
milesthedisch Aug 6, 2022
fda2fcc
Update seed one time route
milesthedisch Aug 10, 2022
d5addb9
Update npm and update mui server render css
milesthedisch Aug 17, 2022
61b1466
Update color scheme.
milesthedisch Sep 1, 2022
5e0b67d
Update colors on menu items and notification items
milesthedisch Sep 1, 2022
1ed7361
Add api key model, Add external api, Update prisma globals
milesthedisch Sep 6, 2022
90afd9b
Add apiKeys and apiKeys admin page
milesthedisch Sep 6, 2022
7845ca2
Add reset password api route
milesthedisch Sep 8, 2022
617a035
Add new fund, huge update
milesthedisch Oct 25, 2022
2358516
Update momentum seed
milesthedisch Oct 25, 2022
429e39c
Update seed file to include new data
milesthedisch Oct 25, 2022
cc89f67
Fix linting key jsx issue
milesthedisch Oct 25, 2022
59079ed
Fix bug with undefined array
milesthedisch Oct 25, 2022
0cdb0fc
Update series
milesthedisch Oct 25, 2022
9466f1a
Update account balance and chart to fix bug when use only has one typ…
milesthedisch Oct 25, 2022
5f65d06
Update seed, Update graph for one user.
milesthedisch Oct 25, 2022
0c55ce5
Fix small bugs with graph and deltas
milesthedisch Oct 26, 2022
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
10 changes: 9 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"extends": ["next", "prettier"],
"plugins": ["react", "import"]
"plugins": ["react", "import"],
"rules": {
"no-restricted-imports": [
"error",
{
"patterns": ["@mui/*/*/*", "!@mui/material/test-utils/*"]
}
]
}
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand All @@ -16,3 +17,9 @@ yarn-error.log*

# Next.js
/.next
.vercel
sendgrid.env
sendgrid.env

/pscale_dump_balmoral-digital_revert-price-change
/pscale_dump*
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# hedgefund-dashboard

Dashboard for hedge fund clients and admin to monitor Profit and Losses

# deploy

This is a
33 changes: 33 additions & 0 deletions __tests__/pages/api/user/create.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { createMocks } from "node-mocks-http";
import { Prisma } from "@prisma/client";
import handleCreate from "../../../../pages/api/user/create";

const TEST_USER: Prisma.UserCreateInput = {
firstName: "John",
lastName: "Doe",
email: "[email protected]",
auth0UserId: 1,
role: "USER",
activated: false,
fullName: "John Doe",
units: 0,
address: null,
};

describe("/api/user/create", () => {
test("returns a message with most of user properties", async () => {
const { req, res } = createMocks({
method: "POST",
body: TEST_USER,
});

await handleCreate(req, res);

expect(res._getStatusCode()).toBe(200);

// we dont check for date as its generated in the db
expect(JSON.parse(res._getData())).toMatchObject({
...TEST_USER,
});
});
});
16 changes: 16 additions & 0 deletions __tests__/pages/db/user/create.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Prisma } from "@prisma/client";
import { prismaMock } from "../../../../db/singleton";
import createUser from "../../../../db/user/create";

test("should create new user ", async () => {
const user: Prisma.UserCreateInput = {
firstName: "Test",
lastName: "Test",
email: "[email protected]",
auth0UserId: 1,
};

prismaMock.user.create.mockResolvedValue(user);

await expect(createUser(user)).resolves.toEqual(user);
});
10 changes: 10 additions & 0 deletions db/apiKeys/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { prisma } from "../client";
import crypto from "crypto";

export default async function create(user: string) {
return prisma.apiKey.create({
data: {
user,
},
});
}
12 changes: 12 additions & 0 deletions db/apiKeys/deleteOne.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { prisma } from "../client";
import crypto from "crypto";

export default async function deleteOne(apiKeyID: string) {
const apiKey = crypto.randomUUID();

return prisma.apiKey.delete({
where: {
apiKeyID,
},
});
}
9 changes: 9 additions & 0 deletions db/apiKeys/findUnique.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { prisma } from "../client";

export default async function findUnique(key: string) {
return prisma.apiKey.findUnique({
where: {
apiKeyID: key,
},
});
}
5 changes: 5 additions & 0 deletions db/apiKeys/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { prisma } from "../client";

export default async function getAll() {
return prisma.apiKey.findMany();
}
15 changes: 15 additions & 0 deletions db/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PrismaClient } from '@prisma/client'

declare global {
// allow global `var` declarations
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined
}

export const prisma =
global.prisma ||
new PrismaClient({
log: ['query', 'info', 'warn', 'error'],
})

if (process.env.NODE_ENV !== 'production') global.prisma = prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `ApiKey` (
`apiKeyID` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`user` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
UNIQUE KEY `ApiKey_apiKeyID_key` (`apiKeyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `ApiKey`(`apiKeyID`,`user`) VALUES
("8da5ec80-3ffb-4770-817e-f69ef62613da","Navexa");
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `ProductionSharePrice` (
`datetime` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`price` decimal(9,6) NOT NULL DEFAULT '0.000000',
UNIQUE KEY `ProductionSharePrice_datetime_key` (`datetime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
INSERT INTO `ProductionSharePrice`(`datetime`,`price`) VALUES
("2022-01-02 20:00:00.000",1.000000),
("2022-01-05 20:00:00.000",1.010000),
("2022-01-08 20:00:00.000",1.050000),
("2022-01-11 20:00:00.000",1.054000),
("2022-01-14 20:00:00.000",1.068000),
("2022-01-17 20:00:00.000",1.073000),
("2022-01-20 20:00:00.000",1.088000),
("2022-01-23 20:00:00.000",1.075000),
("2022-01-26 20:00:00.000",1.074000),
("2022-01-29 20:00:00.000",1.074000),
("2022-02-01 20:00:00.000",1.079000),
("2022-02-04 20:00:00.000",1.080100),
("2022-02-07 20:00:00.000",1.084300),
("2022-02-10 20:00:00.000",1.063400),
("2022-02-13 20:00:00.000",1.076100),
("2022-02-16 20:00:00.000",1.080300),
("2022-02-19 20:00:00.000",1.086600),
("2022-02-22 20:00:00.000",1.086600),
("2022-02-25 20:00:00.000",1.094200),
("2022-02-28 20:00:00.000",1.096100),
("2022-03-03 20:00:00.000",1.102400),
("2022-03-06 20:00:00.000",1.103000),
("2022-03-09 20:00:00.000",1.103000),
("2022-03-12 20:00:00.000",1.096700),
("2022-03-15 20:00:00.000",1.099000),
("2022-03-18 20:00:00.000",1.098600),
("2022-03-21 20:00:00.000",1.099000),
("2022-03-24 20:00:00.000",1.099700),
("2022-03-27 20:00:00.000",1.100900),
("2022-03-30 20:00:00.000",1.100800),
("2022-04-02 20:00:00.000",1.093800),
("2022-04-05 20:00:00.000",1.100900),
("2022-04-08 20:00:00.000",1.100000),
("2022-04-11 20:00:00.000",1.096700),
("2022-04-14 20:00:00.000",1.096700),
("2022-04-17 20:00:00.000",1.107200),
("2022-04-20 20:00:00.000",1.110200),
("2022-04-23 20:00:00.000",1.111200),
("2022-04-26 20:00:00.000",1.113200),
("2022-04-29 20:00:00.000",1.113500),
("2022-05-02 20:00:00.000",1.111600),
("2022-05-05 20:00:00.000",1.097100),
("2022-05-08 20:00:00.000",1.098600),
("2022-05-11 20:00:00.000",1.104700),
("2022-05-14 20:00:00.000",1.104900),
("2022-05-17 20:00:00.000",1.106400),
("2022-05-20 20:00:00.000",1.105100),
("2022-05-23 20:00:00.000",1.107200),
("2022-05-26 20:00:00.000",1.109400),
("2022-05-29 20:00:00.000",1.105500),
("2022-06-01 20:00:00.000",1.105500),
("2022-06-04 20:00:00.000",1.102900),
("2022-06-07 20:00:00.000",1.103500),
("2022-06-10 20:00:00.000",1.104100),
("2022-06-13 20:00:00.000",1.118900),
("2022-06-16 20:00:00.000",1.142600),
("2022-06-19 20:00:00.000",1.144300),
("2022-06-22 20:00:00.000",1.143300),
("2022-06-25 20:00:00.000",1.133200),
("2022-06-28 20:00:00.000",1.138200),
("2022-07-01 20:00:00.000",1.145900),
("2022-07-04 20:00:00.000",1.149800),
("2022-07-07 20:00:00.000",1.144400),
("2022-09-06 23:42:05.622",1.122040),
("2022-09-07 00:05:41.145",1.122564),
("2022-09-08 02:08:07.656",1.123700),
("2022-09-12 23:43:53.945",1.125253);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE `Strategies` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `Strategies_name_key` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
INSERT INTO `Strategies`(`id`,`name`) VALUES
(8,"CBA Cash"),
(17,"Coinspot"),
(2,"Francium Delta Netural"),
(13,"FTT Rebate"),
(9,"FTX USD"),
(11,"IB Fund For Hedging"),
(10,"IB Net Liquidation Value"),
(12,"IB P&L on FX Hedging"),
(15,"Kraken AUD"),
(16,"Kraken USD"),
(7,"Kraken USDT"),
(18,"Kraken UST"),
(1,"SOL (USD Value)"),
(19,"SOL Cold Wallet"),
(4,"Terra Cold Wallet"),
(5,"Terra Hot Wallet"),
(3,"Terra Station Wallet"),
(14,"UST"),
(6,"WW UST Cold");
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE `StrategyTransactions` (
`id` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`datetime` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`balance` decimal(65,30) NOT NULL DEFAULT '0.000000000000000000000000000000',
`strategyId` int NOT NULL,
UNIQUE KEY `StrategyTransactions_id_key` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Loading