Skip to content

Commit 6e60ebe

Browse files
committed
2 parents c952d24 + 986ef7e commit 6e60ebe

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

apps/console/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export default function App() {
178178
</div>
179179
</main>
180180

181-
{/* Form Sheet */}
181+
{/* Form Dialog */}
182182
{showForm && client && selectedObject && (
183183
<ObjectDataForm
184184
client={client}

apps/console/src/components/ObjectDataForm.tsx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Textarea } from "@/components/ui/textarea";
66
import { Label } from "@/components/ui/label";
77
import { Switch } from "@/components/ui/switch";
88
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
9-
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetFooter } from "@/components/ui/sheet";
9+
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from "@/components/ui/dialog";
1010
import { ScrollArea } from "@/components/ui/scroll-area";
1111
import { Badge } from "@/components/ui/badge";
1212
import { Save, Loader2, AlertCircle } from "lucide-react";
@@ -30,9 +30,10 @@ export function ObjectDataForm({ client, objectApiName, record, onSuccess, onCan
3030
async function loadDef() {
3131
if (!client) return;
3232
try {
33-
const found = await client.meta.getItem('object', objectApiName);
33+
const found: any = await client.meta.getItem('object', objectApiName);
3434
if (mounted && found) {
35-
setDef(found);
35+
const resolved = found.data || found;
36+
setDef(resolved);
3637
if (record) {
3738
setFormData({ ...record });
3839
} else {
@@ -98,25 +99,25 @@ export function ObjectDataForm({ client, objectApiName, record, onSuccess, onCan
9899
const isEdit = !!(record && (record.id || record._id));
99100

100101
return (
101-
<Sheet open={true} onOpenChange={(open) => !open && onCancel()}>
102-
<SheetContent className="w-full sm:max-w-lg flex flex-col p-0 gap-0">
103-
<SheetHeader className="px-6 py-4 border-b">
102+
<Dialog open={true} onOpenChange={(open) => !open && onCancel()}>
103+
<DialogContent className="sm:max-w-lg max-h-[85vh] flex flex-col p-0 gap-0">
104+
<DialogHeader className="px-6 pt-6 pb-4 border-b">
104105
<div className="flex items-center gap-2">
105-
<SheetTitle className="text-lg">
106+
<DialogTitle className="text-lg">
106107
{isEdit ? 'Edit' : 'New'} {def.label}
107-
</SheetTitle>
108+
</DialogTitle>
108109
<Badge variant={isEdit ? "secondary" : "default"} className="text-xs">
109110
{isEdit ? 'Editing' : 'Creating'}
110111
</Badge>
111112
</div>
112-
<SheetDescription>
113-
{isEdit
114-
? `Update the fields below to modify this ${def.label.toLowerCase()}.`
113+
<DialogDescription>
114+
{isEdit
115+
? `Update the fields below to modify this ${def.label.toLowerCase()}.`
115116
: `Fill in the fields below to create a new ${def.label.toLowerCase()}.`
116117
}
117-
</SheetDescription>
118-
</SheetHeader>
119-
118+
</DialogDescription>
119+
</DialogHeader>
120+
120121
<form onSubmit={handleSubmit} className="flex-1 flex flex-col overflow-hidden">
121122
<ScrollArea className="flex-1">
122123
<div className="p-6 space-y-5">
@@ -126,7 +127,7 @@ export function ObjectDataForm({ client, objectApiName, record, onSuccess, onCan
126127
{error}
127128
</div>
128129
)}
129-
130+
130131
{fieldKeys.map(key => {
131132
const field = fields[key];
132133
const label = field.label || key;
@@ -145,7 +146,7 @@ export function ObjectDataForm({ client, objectApiName, record, onSuccess, onCan
145146
{field.type}
146147
</Badge>
147148
</div>
148-
149+
149150
{field.type === 'boolean' ? (
150151
<div className="flex items-center gap-3 rounded-lg border p-3">
151152
<Switch
@@ -202,7 +203,7 @@ export function ObjectDataForm({ client, objectApiName, record, onSuccess, onCan
202203
</div>
203204
</ScrollArea>
204205

205-
<SheetFooter className="px-6 py-4 border-t bg-muted/30 flex items-center gap-2 sm:justify-end">
206+
<DialogFooter className="px-6 py-4 border-t bg-muted/30">
206207
<Button variant="outline" onClick={onCancel} type="button" className="gap-1.5">
207208
Cancel
208209
</Button>
@@ -217,9 +218,9 @@ export function ObjectDataForm({ client, objectApiName, record, onSuccess, onCan
217218
</>
218219
)}
219220
</Button>
220-
</SheetFooter>
221+
</DialogFooter>
221222
</form>
222-
</SheetContent>
223-
</Sheet>
223+
</DialogContent>
224+
</Dialog>
224225
);
225226
}

0 commit comments

Comments
 (0)