Skip to content

Commit

Permalink
page is removed from components
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafabarmshory committed Jan 12, 2023
1 parent 2004c57 commit 5c35042
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 34 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/core/card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { OCard } from './card';
export {
OCard,
};
File renamed without changes.
4 changes: 4 additions & 0 deletions src/core/chart/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { OChart } from "./chart";
export {
OChart,
}
32 changes: 6 additions & 26 deletions src/components/page.ts → src/core/pages.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,42 @@
import { Component, useState } from "@odoo/owl";
import { registry } from "../core/registry";
import { registry } from "./registry";

export const route = (path: string) => {
return (target: any) => {
target.route = path;
registry.category('pages').add(path, target);
}
}

export const template = (name: string) => {
return (target: any) => {
target.template = name;
}
}

export const logo = (path: string) => {
return (target: any) => {
target.logo = path;
}
}

export const title = (title: string) => {
return (target: any) => {
target.title = title;
}
}

export const symbol = (name: string) => {
return (target: any) => {
target.symbol = name;
}
}

export const enableStaking = () => {
return (target: any) => {
target.enableStaking = true;
}
}

/**
* Abstract Page
*
* All pages must inherid directly from this component.
*/
export abstract class OPage extends Component {

pageInfo = useState({
title: ""
});

/**
* Replace title of the page.
*
* @param title of the current page
* @returns the current page
*/
public setTitle(title: string): OPage {
this.pageInfo.title = title;
// TODO: update title of the current page
return this;
}
}


export function usePage(path: string, page: any) {
// TODO;;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/csc/csc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CSC Network
*/
import { Component, useState } from "@odoo/owl";
import { enableStaking, logo, route, symbol, template, title } from "../../components/page";
import { enableStaking, logo, route, symbol, template, title } from "../../core/pages";
import { switchChain, useContract, useWallet } from "../../core/wallet";

import cetABI from "./abi-validators.json";
Expand Down
8 changes: 4 additions & 4 deletions src/pages/dashboard/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { xml, useState, Component } from "@odoo/owl";
import { OPage, route, template, title } from "../../components/page";
import { registry } from "../../core/registry";
import { Component, useState } from "@odoo/owl";
import { route, template, title } from "../../core/pages";
import { Button } from "../../core/buttons";
import { registry } from "../../core/registry";

import "./dashboard.xml";

Expand All @@ -11,7 +11,7 @@ import "./dashboard.xml";
export class Dashboard extends Component {
static components = {Button};
state: {
pages: OPage[]
pages: Component[]
} = useState({
pages: []
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/fantom/fantom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Symbol: FTM


import { Component, useState } from "@odoo/owl";
import { enableStaking, logo, route, symbol, template, title } from "../../core/pages";
import { switchChain, useContract, useWallet } from "../../core/wallet";
import { enableStaking, logo, route, symbol, template, title } from "../../components/page";

import FantomABI from "./abi-fantom.json";
import "./fantom.scss";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/polygon/polygon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, useState } from "@odoo/owl";
import { enableStaking, logo, route, symbol, template, title } from "../../components/page";
import { enableStaking, logo, route, symbol, template, title } from "../../core/pages";
import { switchChain, useContract, useWallet } from "../../core/wallet";


Expand Down
2 changes: 1 addition & 1 deletion src/pages/sgton/sgton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TODO: add documents
*/
import { Component, useState } from "@odoo/owl";
import { enableStaking, logo, route, template, title } from "../../components/page";
import { enableStaking, logo, route, template, title } from "../../core/pages";
import { switchChain, useContract, useWallet } from "../../core/wallet";


Expand Down

0 comments on commit 5c35042

Please sign in to comment.