chore: some optimizations
This commit is contained in:
@@ -200,6 +200,20 @@ function BuildArgRow({
|
|||||||
setIsEditing(false);
|
setIsEditing(false);
|
||||||
}, [argName, arg, onFinish]);
|
}, [argName, arg, onFinish]);
|
||||||
|
|
||||||
|
const onArgNameChange = useCallback(
|
||||||
|
(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setArgName(event.currentTarget.value);
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const onArgChange = useCallback(
|
||||||
|
(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setArg(event.currentTarget.value);
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Input
|
<Input
|
||||||
@@ -207,18 +221,14 @@ function BuildArgRow({
|
|||||||
disabled={!isEditing}
|
disabled={!isEditing}
|
||||||
placeholder="Argument name"
|
placeholder="Argument name"
|
||||||
value={argName}
|
value={argName}
|
||||||
onChange={(event) => {
|
onChange={onArgNameChange}
|
||||||
setArgName(event.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
disabled={!isEditing}
|
disabled={!isEditing}
|
||||||
placeholder="Argument value"
|
placeholder="Argument value"
|
||||||
value={arg}
|
value={arg}
|
||||||
onChange={(event) => {
|
onChange={onArgChange}
|
||||||
setArg(event.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
|
@@ -21,6 +21,7 @@ import dayjs from "dayjs";
|
|||||||
import { Pencil, Plus, Trash2 } from "lucide-react";
|
import { Pencil, Plus, Trash2 } from "lucide-react";
|
||||||
import { useDeleteTemplate, useTemplates } from "./api";
|
import { useDeleteTemplate, useTemplates } from "./api";
|
||||||
import { NewTemplateDialog } from "./new-template-dialog";
|
import { NewTemplateDialog } from "./new-template-dialog";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
function TemplatesDashboard() {
|
function TemplatesDashboard() {
|
||||||
return (
|
return (
|
||||||
@@ -30,26 +31,33 @@ function TemplatesDashboard() {
|
|||||||
</aside>
|
</aside>
|
||||||
<Page>
|
<Page>
|
||||||
<PageHeader>Templates</PageHeader>
|
<PageHeader>Templates</PageHeader>
|
||||||
<Dialog>
|
<Main />
|
||||||
<main>
|
|
||||||
<DialogTrigger asChild>
|
|
||||||
<div className="flex flex-row py-4">
|
|
||||||
<Button variant="secondary" size="sm">
|
|
||||||
<Plus /> New template
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</DialogTrigger>
|
|
||||||
<TemplateTable />
|
|
||||||
</main>
|
|
||||||
<NewTemplateDialog />
|
|
||||||
</Dialog>
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</Page>
|
</Page>
|
||||||
</SidebarProvider>
|
</SidebarProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TemplateTable() {
|
function Main() {
|
||||||
|
return (
|
||||||
|
<Dialog>
|
||||||
|
<main>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<div className="flex flex-row py-4">
|
||||||
|
<Button variant="secondary" size="sm">
|
||||||
|
<Plus /> New template
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</DialogTrigger>
|
||||||
|
<TemplateTable />
|
||||||
|
</main>
|
||||||
|
<NewTemplateDialog />
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TemplateTable = React.memo(_TemplateTable, () => true);
|
||||||
|
function _TemplateTable() {
|
||||||
const { data: templates, isLoading } = useTemplates();
|
const { data: templates, isLoading } = useTemplates();
|
||||||
const deleteTemplate = useDeleteTemplate();
|
const deleteTemplate = useDeleteTemplate();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
@@ -58,7 +58,6 @@ function createTemplateEditorStore({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
if (isApiErrorResponse(error)) {
|
if (isApiErrorResponse(error)) {
|
||||||
console.log("askdjskdjk");
|
|
||||||
set({ buildError: error });
|
set({ buildError: error });
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
Reference in New Issue
Block a user