Skip to content

Commit

Permalink
added stats for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
dendidibe committed Aug 16, 2023
1 parent 0021041 commit a6900aa
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 183 deletions.
37 changes: 32 additions & 5 deletions client-web/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export interface IDefaultChatRoom {
title: string;
}
export interface IUserDefaults {
defaultAccessProfileOpen: boolean,
defaultAccessAssetsOpen: boolean,
usersCanFree: boolean,
defaultRooms: Omit<IDefaultChatRoom, 'title'>[]
defaultAccessProfileOpen: boolean;
defaultAccessAssetsOpen: boolean;
usersCanFree: boolean;
defaultRooms: Omit<IDefaultChatRoom, "title">[];
}
export type TUser = {
firstName: string;
Expand Down Expand Up @@ -283,6 +283,31 @@ export async function deployNfmt(
}
}

interface GraphData {
apiCallCount: number;
apiCalls: { y: string[]; x: string[] };
issuance: { y: string[]; x: string[] };
issuanceCount: number;
sessions: { y: string[]; x: string[] };
sessionsCount: number;
transactions: { y: string[]; x: string[] };
transactionsCount: number;
}

export const getGraphs = (
appId: string,
startDate: string,
endDate: string
) => {
const params = new URLSearchParams();
params.append("startDate", startDate);
params.append("endDate", endDate);

return httpWithAuth().get<GraphData>(
"/apps/graph-statistic/" + appId + "?" + params.toString()
);
};

export function getBalance(walletAddress: string) {
const user = useStoreState.getState().user;
return http.get(`/wallets/balance`, {
Expand Down Expand Up @@ -582,7 +607,9 @@ export function changeUserDefaults(appId: string, data: IUserDefaults) {
export function getDefaultChats() {
const appToken = useStoreState.getState().config.appToken;

return httpWithToken(appToken).get<IDefaultChatRoom[]>("/apps/get-default-rooms");
return httpWithToken(appToken).get<IDefaultChatRoom[]>(
"/apps/get-default-rooms"
);
}
export function createApp(fd: FormData) {
const owner = useStoreState.getState().user;
Expand Down
11 changes: 8 additions & 3 deletions client-web/src/pages/Owner/Apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useSnackbar } from "../../context/SnackbarContext";
import { useHistory } from "react-router";
import SettingsIcon from "@mui/icons-material/Settings";
import { AppsTableHead } from "../../components/AppsTable/AppsTableHead";
import LeaderboardIcon from '@mui/icons-material/Leaderboard';

const COINS_TO_CREATE_APP = 10;

Expand Down Expand Up @@ -194,7 +195,7 @@ export default function Apps({ onRowClick }: Props) {
</span>
</TableCell>
<TableCell sx={{ fontWeight: "bold" }} align="center">
{app.stats?.totalTransactions.toLocaleString("en-US")}
{app.stats?.totalTransactions.toLocaleString("en-US")}
<span style={{ fontWeight: "bold", color: "green" }}>
{" "}
+{app.stats?.recentlyTransactions}
Expand All @@ -208,13 +209,17 @@ export default function Apps({ onRowClick }: Props) {
<Box
style={{
display: "flex",
flexDirection: "column",
alignItems: "flex-end",
alignItems: "center",
justifyContent: 'flex-end'

}}
>
<IconButton onClick={() => onEdit(app)}>
<SettingsIcon color="primary" />
</IconButton>
<IconButton onClick={() => history.push('/statistics/' + app._id)}>
<LeaderboardIcon color="primary" />
</IconButton>
</Box>
</TableCell>
</TableRow>
Expand Down
2 changes: 1 addition & 1 deletion client-web/src/pages/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const Routes = () => {
<AuthRoute path="/privacy" component={Privacy} />
<AuthRoute path="/newchat" component={NewChat} />
<AuthRoute path="/referrals" component={Referrals} />
<AuthRoute path="/statistics" component={StatisticsPage} />
<AuthRoute path="/statistics/:appId" component={StatisticsPage} />
<AuthRoute path="/changebg/:roomJID" component={ChangeBackground} />
<AuthRoute path="/organizations" component={Organizations} />
<AuthRoute path="/payments" component={Subscriptions} />
Expand Down
Loading

0 comments on commit a6900aa

Please sign in to comment.