1"use client";
2import { Model } from "@akanjs/ui";
3import { DefaultOf } from "@akanjs/constant";
4
5interface CardProps {
6 className?: string;
7 init: ClientInit<"icecreamOrder", cnst.LightIcecreamOrder>;
8}
9export const Card = ({ className, init }: CardProps) => {
10 return (
11 <>
12 <Load.Units
13 className={className}
14 init={init}
15 renderItem={(icecreamOrder: cnst.LightIcecreamOrder) => (
16 <IcecreamOrder.Unit.Card
17 key={icecreamOrder.id}
18 icecreamOrder={icecreamOrder}
19 />
20 )}
21 />
22 <Model.ViewEditModal
23 sliceName="icecreamOrderInPublic"
24 renderTitle={(icecreamOrder: DefaultOf<cnst.IcecreamOrder>) =>
25 `IcecreamOrder - ${icecreamOrder.id ? icecreamOrder.id : "New"}`
26 }
27 renderView={(icecreamOrder: cnst.IcecreamOrder) => (
28 <IcecreamOrder.View.General className="w-full" icecreamOrder={icecreamOrder} />
29 )}
30 renderTemplate={() => <IcecreamOrder.Template.General />}
31 />
32 </>
33 );
34};
35
36// ... existing code ...1import { clsx, ModelProps } from "@akanjs/client";
2import { Model } from "@akanjs/ui";
3import { cnst, usePage } from "@koyo/client";
4
5export const Card = ({ icecreamOrder }: ModelProps<"icecreamOrder", cnst.LightIcecreamOrder>) => {
6 const { l } = usePage();
7 return (
8 <div className="group flex h-36 w-full overflow-hidden rounded-xl bg-linear-to-br from-pink-100 via-yellow-50 to-pink-200 px-8 py-6 shadow-md transition-all duration-300 hover:shadow-xl">
9 <div className="flex w-full flex-col justify-center">
10 <div className="flex items-center gap-2 text-lg font-semibold text-pink-700">
11 <span className="inline-block rounded bg-pink-200 px-2 py-1 text-xs font-bold tracking-wider uppercase">
12 {l("icecreamOrder.id")}
13 </span>
14 <span className="ml-2 font-mono text-pink-900">#{icecreamOrder.id.slice(-4)}</span>
15 </div>
16 <div className="mt-4 flex items-center gap-2">
17 <span className="inline-block rounded bg-yellow-200 px-2 py-1 text-xs font-bold tracking-wider text-yellow-800 uppercase">
18 {l("icecreamOrder.status")}
19 </span>
20 <span
21 className={clsx("ml-2 rounded-full px-3 py-1 text-sm font-semibold", {
22 "bg-green-100 text-green-700": icecreamOrder.status === "active",
23 "bg-blue-100 text-blue-700": icecreamOrder.status === "processing",
24 "bg-red-100 text-red-700": icecreamOrder.status === "served",
25 "bg-purple-100 text-purple-700": icecreamOrder.status === "finished",
26 "bg-gray-100 text-gray-700": icecreamOrder.status === "canceled",
27 })}
28 >
29 {l(`icecreamOrderStatus.${icecreamOrder.status}`)}
30 </span>
31 </div>
32 </div>
33 <div className="bg-base-100/50 flex items-center justify-center gap-2 rounded-xl p-4">
34 <Model.ViewWrapper sliceName="icecreamOrder" modelId={icecreamOrder.id}>
35 <button className="btn btn-primary">
36 <span>{l.trans({ en: "View", ko: "보기" })}</span>
37 </button>
38 </Model.ViewWrapper>
39 </div>
40 </div>
41 );
42};1import { clsx } from "@akanjs/client";
2import { cnst, usePage } from "@koyo/client";
3
4interface IcecreamOrderViewProps {
5 className?: string;
6 icecreamOrder: cnst.IcecreamOrder;
7}
8
9export const General = ({ className, icecreamOrder }: IcecreamOrderViewProps) => {
10 const { l } = usePage();
11 return (
12 <div className={clsx(className, "mx-auto w-full space-y-6 rounded-xl p-8 shadow-lg")}>
13 {/* Header with icon and title */}
14 <div className="flex items-center gap-3 border-b pb-4">
15 <span className="text-3xl font-extrabold text-pink-600">🍦</span>
16 <span className="text-2xl font-bold">{l("icecreamOrder.modelName")}</span>
17 <span className="ml-auto text-xs text-base-content/50">#{icecreamOrder.id}</span>
18 </div>
19
20 {/* Order details in a grid layout */}
21 <div className="grid grid-cols-2 gap-x-6 gap-y-4">
22 {/* Size information */}
23 <div className="font-semibold text-base-content/50">{l("icecreamOrder.size")}</div>
24 <div>{icecreamOrder.size} cc</div>
25
26 {/* Toppings information */}
27 <div className="font-semibold text-base-content/50">{l("icecreamOrder.toppings")}</div>
28 <div className="flex flex-wrap gap-2">
29 {icecreamOrder.toppings.length === 0 ? (
30 <span className="italic text-gray-400">
31 {l.trans({ en: "No toppings", ko: "토핑 없음" })}
32 </span>
33 ) : (
34 icecreamOrder.toppings.map((topping) => (
35 <span
36 key={topping}
37 className="inline-block rounded-full bg-pink-100 px-2 py-1 text-xs font-medium text-pink-700"
38 >
39 {l(`topping.${topping}`)}
40 </span>
41 ))
42 )}
43 </div>
44
45 {/* Status information */}
46 <div className="font-semibold text-base-content/50">{l("icecreamOrder.status")}</div>
47 <div>
48 <span
49 className={clsx("inline-block rounded-full px-2 py-1 text-xs font-semibold", {
50 "bg-green-100 text-green-700": icecreamOrder.status === "active",
51 "bg-yellow-100 text-yellow-700": icecreamOrder.status === "processing",
52 "bg-red-100 text-red-700": icecreamOrder.status === "served",
53 "bg-purple-100 text-purple-700": icecreamOrder.status === "finished",
54 "bg-gray-100 text-gray-700": icecreamOrder.status === "canceled",
55 })}
56 >
57 {l(`icecreamOrderStatus.${icecreamOrder.status}`)}
58 </span>
59 </div>
60
61 {/* Timestamps */}
62 <div className="font-semibold text-base-content/50">{l("icecreamOrder.createdAt")}</div>
63 <div className="text-gray-500">{icecreamOrder.createdAt.format("YYYY-MM-DD HH:mm:ss")}</div>
64
65 <div className="font-semibold text-base-content/50">{l("icecreamOrder.updatedAt")}</div>
66 <div className="text-gray-500">{icecreamOrder.updatedAt.format("YYYY-MM-DD HH:mm:ss")}</div>
67 </div>
68 </div>
69 );
70};