// Basic Zone component structure
"use client";
import { Load, Data } from "@akanjs/ui";
import { ModelsProps } from "@akanjs/client";
import { ClientInit, ClientView } from "@akanjs/signal";
import { Model } from "./index";
export const Admin = ({ sliceName = "model", init, query }: ModelsProps<cnst.Model>) => {
return (
<Data.ListContainer
init={init}
query={query}
sliceName={sliceName}
renderItem={Model.Unit.Card}
renderTemplate={Model.Template.General}
renderView={(model) => <Model.View.General model={model} />}
columns={["id", "status", "createdAt"]}
actions={(model) => ["remove", "edit", "view"]}
/>
);
};
export const Zone = {
Admin,
// Additional components...
};
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
Model.Zone.Admin
Detailed view of a single model instance
Model.Zone.View
List display of model items as cards
Model.Zone.Card
Custom layout for model-specific dashboards
Model.Zone.Dashboard
export const Admin = ({ sliceName = "model", init, query }: ModelsProps<cnst.Model>) => (
<Data.ListContainer
init={init}
query={query}
sliceName={sliceName}
renderItem={Model.Unit.Card}
renderTemplate={Model.Template.General}
renderView={(model) => <Model.View.General model={model} />}
columns={["id", "name", "status"]}
actions={(model) => ["remove", "edit", "view"]}
/>
);
export const View = ({ view }: { view: ClientView<"model", cnst.Model> }) => (
<Load.View
view={view}
renderView={(model) => <Model.View.General model={model} />}
/>
);
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
"product"
Initialization data for the component
modelInit
Query parameters for data fetching
{ status: 'active' }
Custom styling classes
"p-4 bg-base-200"
// Page component integration
export default function ModelPage() {
return (
<Load.Page
loader={async () => {
const { modelInit } = await fetch.initModel();
return { modelInit };
}}
render={({ modelInit }) => (
<div className="container mx-auto p-4">
<Model.Zone.Card init={modelInit} />
</div>
)}
/>
);
}
// Real-time data integration
export const LiveFeed = ({ init }: { init: ClientInit<"model"> }) => {
useEffect(() => {
const unsubscribe = subscriptions.subscribeToModelUpdates();
return () => unsubscribe();
}, []);
return (
<Load.Units
init={init}
renderItem={(model) => <Model.Unit.Card model={model} />}
/>
);
};
// Conditional rendering
export const Card = ({ init, variant }) => (
<Load.Units
init={init}
renderItem={(model) => {
switch (variant) {
case "compact":
return <Model.Unit.CompactCard model={model} />;
default:
return <Model.Unit.Card model={model} />;
}
}}
/>
);
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 |