1
2// Basic Zone component structure
3"use client";
4
5import { Load, Data } from "@akanjs/ui";
6import { ModelsProps } from "@akanjs/client";
7import { ClientInit, ClientView } from "@akanjs/signal";
8import { Model } from "./index";
9
10export const Admin = ({ sliceName = "model", init, query }: ModelsProps<cnst.Model>) => {
11 return (
12 <Data.ListContainer
13 init={init}
14 query={query}
15 sliceName={sliceName}
16 renderItem={Model.Unit.Card}
17 renderTemplate={Model.Template.General}
18 renderView={(model) => <Model.View.General model={model} />}
19 columns={["id", "status", "createdAt"]}
20 actions={(model) => ["remove", "edit", "view"]}
21 />
22 );
23};
24
25export const Zone = {
26 Admin,
27 // Additional components...
28};
29 | zoneType | Description | Example |
|---|---|---|
| Admin | Administrative interface with CRUD operations | |
| View | Detailed view of a single model instance | |
| Card | List display of model items as cards | |
| Dashboard | Custom layout for model-specific dashboards | |
Administrative interface with CRUD operations
1Model.Zone.AdminDetailed view of a single model instance
1Model.Zone.ViewList display of model items as cards
1Model.Zone.CardCustom layout for model-specific dashboards
1Model.Zone.Dashboard1
2export const Admin = ({ sliceName = "model", init, query }: ModelsProps<cnst.Model>) => (
3 <Data.ListContainer
4 init={init}
5 query={query}
6 sliceName={sliceName}
7 renderItem={Model.Unit.Card}
8 renderTemplate={Model.Template.General}
9 renderView={(model) => <Model.View.General model={model} />}
10 columns={["id", "name", "status"]}
11 actions={(model) => ["remove", "edit", "view"]}
12 />
13);
14 1
2export const View = ({ view }: { view: ClientView<"model", cnst.Model> }) => (
3 <Load.View
4 view={view}
5 renderView={(model) => <Model.View.General model={model} />}
6 />
7);
8 | Option | Type | Default | Description | Example |
|---|---|---|---|---|
| sliceName | string | model | Name for data slice in global state | |
| init | ClientInit<model> | undefined | Initialization data for the component | |
| query | QueryProps | {} | Query parameters for data fetching | |
| className | string | undefined | Custom styling classes | |
Name for data slice in global state
1"product"Initialization data for the component
1modelInitQuery parameters for data fetching
1{ status: 'active' }Custom styling classes
1"p-4 bg-base-200"1
2// Page component integration
3export default function ModelPage() {
4 return (
5 <Load.Page
6 loader={async () => {
7 const { modelInit } = await fetch.initModel();
8 return { modelInit };
9 }}
10 render={({ modelInit }) => (
11 <div className="container mx-auto p-4">
12 <Model.Zone.Card init={modelInit} />
13 </div>
14 )}
15 />
16 );
17}
18 1
2// Real-time data integration
3export const LiveFeed = ({ init }: { init: ClientInit<"model"> }) => {
4 useEffect(() => {
5 const unsubscribe = subscriptions.subscribeToModelUpdates();
6 return () => unsubscribe();
7 }, []);
8
9 return (
10 <Load.Units
11 init={init}
12 renderItem={(model) => <Model.Unit.Card model={model} />}
13 />
14 );
15};
16
17// Conditional rendering
18export const Card = ({ init, variant }) => (
19 <Load.Units
20 init={init}
21 renderItem={(model) => {
22 switch (variant) {
23 case "compact":
24 return <Model.Unit.CompactCard model={model} />;
25 default:
26 return <Model.Unit.Card model={model} />;
27 }
28 }}
29 />
30);
31 | Issue | Solution |
|---|---|
| Client component rendering error | Add 'use client' directive at top of file |
| Props validation failed | Check ClientInit/ClientView types |
| Data not loading | Verify page component data fetching |