-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
424 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import type { IViewModel, NavigationContext, NoParams } from "@frui.ts/views"; | ||
import { makeObservable, observable, runInAction } from "mobx"; | ||
import type { IViewModel, SearchType } from "@frui.ts/views"; | ||
|
||
export default class CustomersViewModel implements IViewModel { | ||
type SearchScheme = { name?: string }; | ||
|
||
export default class CustomersViewModel implements IViewModel<NoParams, SearchScheme> { | ||
@observable | ||
search?: string; | ||
|
||
constructor() { | ||
makeObservable(this); | ||
} | ||
|
||
onNavigate(search: SearchType) { | ||
onNavigate({ search }: NavigationContext<NoParams, SearchScheme>) { | ||
console.log("customers navigate", search); | ||
|
||
runInAction(() => { | ||
this.search = search.name as string; | ||
this.search = search.name; | ||
}); | ||
} | ||
|
||
onDeactivate(context: NavigationContext<NoParams, SearchScheme>) { | ||
console.log("customers deactivate"); | ||
} | ||
|
||
static validateSearch(search: Record<string, unknown>) { | ||
return { | ||
name: search.name as string | undefined, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import type { IViewModel, NavigationContext } from "@frui.ts/views"; | ||
import { makeObservable, observable, runInAction } from "mobx"; | ||
import type { IViewModel, RouteMatch } from "@frui.ts/views"; | ||
|
||
export default class InvoiceDetailViewModel implements IViewModel { | ||
type ParamsScheme = Record<"invoiceId", string>; | ||
|
||
export default class InvoiceDetailViewModel implements IViewModel<ParamsScheme> { | ||
@observable | ||
id = -1; | ||
|
||
constructor() { | ||
makeObservable(this); | ||
} | ||
|
||
onInitialize(routeMatch: RouteMatch) { | ||
onNavigate({ params }: NavigationContext<ParamsScheme>) { | ||
runInAction(() => { | ||
this.id = +routeMatch.params.id; | ||
this.id = +params.invoiceId; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import type { IViewModel, RouteMatch } from "@frui.ts/views"; | ||
import type { IViewModel, NavigationContext } from "@frui.ts/views"; | ||
|
||
export default class InvoicesViewModel implements IViewModel { | ||
onInitialize(routeMatch: RouteMatch) { | ||
console.log("invoices on initialize", routeMatch); | ||
onInitialize(context: NavigationContext) { | ||
console.log("invoices on initialize", context); | ||
} | ||
|
||
onActivate(routeMatch: RouteMatch) { | ||
console.log("invoices on activate", routeMatch); | ||
onActivate(context: NavigationContext) { | ||
console.log("invoices on activate", context); | ||
} | ||
|
||
onDeactivate(routeMatch: RouteMatch) { | ||
console.log("invoices on deactivate", routeMatch); | ||
onDeactivate(context: NavigationContext) { | ||
console.log("invoices on deactivate", context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
import type { LocationGenerics } from "@frui.ts/views"; | ||
import { buildRoutes, RouteView } from "@frui.ts/views"; | ||
import { ReactLocation, Router } from "@tanstack/react-location"; | ||
import { buildRoute } from "@frui.ts/views"; | ||
import { ReactRouter, RootRoute, RouterProvider } from "@tanstack/react-router"; | ||
import React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import "todomvc-app-css/index.css"; | ||
import "todomvc-common/base.css"; | ||
import ListViewModel from "./list/todoListViewModel"; | ||
import "./viewsRegistry"; | ||
|
||
const location = new ReactLocation<LocationGenerics>(); | ||
const rootRoute = new RootRoute(); | ||
const homeRoute = buildRoute(() => new ListViewModel(), { | ||
getParentRoute: () => rootRoute, | ||
path: "$filter", | ||
}); | ||
|
||
const routes = buildRoutes([ | ||
{ | ||
vmFactory: () => new ListViewModel(), | ||
}, | ||
]); | ||
const routeTree = rootRoute.addChildren([homeRoute]); | ||
|
||
const router = new ReactRouter({ | ||
routeTree, | ||
}); | ||
|
||
declare module "@tanstack/react-router" { | ||
interface Register { | ||
router: typeof router; | ||
} | ||
} | ||
|
||
const container = document.getElementById("root"); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const root = createRoot(container!); | ||
root.render( | ||
<React.StrictMode> | ||
<Router location={location} routes={routes} defaultElement={<RouteView />} /> | ||
<RouterProvider router={router} /> | ||
</React.StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.