1// Basic Zone component structure
2"use client";
3
4import { Load, Data } from "@akanjs/ui";
5import { ModelsProps } from "@akanjs/client";
6import { ClientInit, ClientView } from "@akanjs/signal";
7import { Model } from "./index";
8
9export const Admin = ({ sliceName = "model", init, query }: ModelsProps<cnst.Model>) => {
10 return (
11 <Data.ListContainer
12 init={init}
13 query={query}
14 sliceName={sliceName}
15 renderItem={Model.Unit.Card}
16 renderTemplate={Model.Template.General}
17 renderView={(model) => <Model.View.General model={model} />}
18 columns={["id", "status", "createdAt"]}
19 actions={(model) => ["remove", "edit", "view"]}
20 />
21 );
22};
23
24export const Zone = {
25 Admin,
26 // Additional components...
27};
28 | 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.Dashboard1export const Admin = ({ sliceName = "model", init, query }: ModelsProps<cnst.Model>) => (
2 <Data.ListContainer
3 init={init}
4 query={query}
5 sliceName={sliceName}
6 renderItem={Model.Unit.Card}
7 renderTemplate={Model.Template.General}
8 renderView={(model) => <Model.View.General model={model} />}
9 columns={["id", "name", "status"]}
10 actions={(model) => ["remove", "edit", "view"]}
11 />
12);
13 1export const View = ({ view }: { view: ClientView<"model", cnst.Model> }) => (
2 <Load.View
3 view={view}
4 renderView={(model) => <Model.View.General model={model} />}
5 />
6);
7 | 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// Page component integration
2export default function ModelPage() {
3 return (
4 <Load.Page
5 loader={async () => {
6 const { modelInit } = await fetch.initModel();
7 return { modelInit };
8 }}
9 render={({ modelInit }) => (
10 <div className="container mx-auto p-4">
11 <Model.Zone.Card init={modelInit} />
12 </div>
13 )}
14 />
15 );
16}
17 1// Real-time data integration
2export const LiveFeed = ({ init }: { init: ClientInit<"model"> }) => {
3 useEffect(() => {
4 const unsubscribe = subscriptions.subscribeToModelUpdates();
5 return () => unsubscribe();
6 }, []);
7
8 return (
9 <Load.Units
10 init={init}
11 renderItem={(model) => <Model.Unit.Card model={model} />}
12 />
13 );
14};
15
16// Conditional rendering
17export const Card = ({ init, variant }) => (
18 <Load.Units
19 init={init}
20 renderItem={(model) => {
21 switch (variant) {
22 case "compact":
23 return <Model.Unit.CompactCard model={model} />;
24 default:
25 return <Model.Unit.Card model={model} />;
26 }
27 }}
28 />
29);
30 | 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 |