35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { useSignal, type Signal } from "@preact/signals";
|
|
import { bplan, dplan, Plan, plandb } from "../common/plan.ts";
|
|
|
|
export interface PlanDBProps {
|
|
date: Signal<number>;
|
|
plans: Signal<Plan[]>;
|
|
cplan: Signal<Plan>;
|
|
}
|
|
|
|
export interface PlanDisplayProps {
|
|
plan: Plan;
|
|
add?: (plan: Plan) => any;
|
|
modify?: (plan: Plan) => any;
|
|
del?: (plan: Plan) => any;
|
|
}
|
|
|
|
export function PlanDisplay({ plan, add, modify, del }: PlanDisplayProps) {
|
|
const cplan: Signal<Plan> = useSignal({ ...dplan, ...plan });
|
|
return <div class="plan">
|
|
<pre>{JSON.stringify(cplan.value)}</pre>
|
|
</div>;
|
|
}
|
|
|
|
export default function PlanDB({ date, plans, cplan }: PlanDBProps) {
|
|
return <div class="plandb">
|
|
<div>所有</div>
|
|
<div class="plandb_current">
|
|
{Object.entries(plans.value).map(([k, v]) => <PlanDisplay plan={v} />)}
|
|
</div>
|
|
<div>预设</div>
|
|
<div class="plandb__presets">
|
|
{Object.entries(plandb).map(([k, v]) => <PlanDisplay plan={bplan(v)} />)}
|
|
</div>
|
|
</div>;
|
|
}
|