datajunction-ui
Version:
DataJunction UI
115 lines (114 loc) • 4.62 kB
JavaScript
import { jsxs as a, jsx as e, Fragment as o } from "react/jsx-runtime";
import { D as m, N as p, s as h, r as u, aH as y, o as d, q as r } from "./index-n79cxNwC.js";
import { useContext as g } from "react";
function T() {
const c = g(m).DataJunctionAPI;
return /* @__PURE__ */ a("div", { className: "mid", children: [
/* @__PURE__ */ e(p, { namespace: "" }),
/* @__PURE__ */ e("div", { className: "card", children: /* @__PURE__ */ a("div", { className: "card-header", children: [
/* @__PURE__ */ a("h2", { children: [
"Add",
" ",
/* @__PURE__ */ e("span", { className: "node_type__source node_type_creation_heading", children: "Tag" })
] }),
/* @__PURE__ */ e("center", { children: /* @__PURE__ */ e(
h,
{
initialValues: {
name: ""
},
validate: (n) => {
const t = {};
return n.name || (t.name = "Required"), t;
},
onSubmit: async (n, { setSubmitting: t, setStatus: i }) => {
const { status: l, json: s } = await c.addTag(
n.name,
n.display_name,
n.tag_type,
n.description
);
i(l === 200 || l === 201 ? {
success: /* @__PURE__ */ a(o, { children: [
"Successfully added tag",
" ",
/* @__PURE__ */ e("a", { href: `/tags/${s.name}`, children: s.display_name }),
"."
] })
} : {
failure: `${s.message}`
}), t(!1), window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
},
children: function({ isSubmitting: t, status: i }) {
return /* @__PURE__ */ a(u, { children: [
y(i),
/* @__PURE__ */ a(o, { children: [
/* @__PURE__ */ a("div", { className: "NodeCreationInput", children: [
/* @__PURE__ */ e(d, { name: "name", component: "span" }),
/* @__PURE__ */ e("label", { htmlFor: "name", children: "Name" }),
/* @__PURE__ */ e(
r,
{
type: "text",
name: "name",
id: "name",
placeholder: "Tag Name"
}
)
] }),
/* @__PURE__ */ e("br", {}),
/* @__PURE__ */ a("div", { className: "FullNameInput NodeCreationInput", children: [
/* @__PURE__ */ e(d, { name: "display_name", component: "span" }),
/* @__PURE__ */ e("label", { htmlFor: "display_name", children: "Display Name" }),
/* @__PURE__ */ e(
r,
{
type: "text",
name: "display_name",
id: "display_name",
placeholder: "Display Name",
className: "FullNameField"
}
)
] }),
/* @__PURE__ */ e("br", {}),
/* @__PURE__ */ a("div", { className: "NodeCreationInput", children: [
/* @__PURE__ */ e(d, { name: "tag_type", component: "span" }),
/* @__PURE__ */ e("label", { htmlFor: "tag_type", children: "Tag Type" }),
/* @__PURE__ */ e(
r,
{
type: "text",
name: "tag_type",
id: "tag_type",
placeholder: "Tag Type"
}
)
] }),
/* @__PURE__ */ a("div", { className: "DescriptionInput NodeCreationInput", children: [
/* @__PURE__ */ e(d, { name: "description", component: "span" }),
/* @__PURE__ */ e("label", { htmlFor: "description", children: "Description" }),
/* @__PURE__ */ e(
r,
{
type: "textarea",
as: "textarea",
name: "description",
id: "Description",
placeholder: "Describe the tag"
}
)
] }),
/* @__PURE__ */ e("button", { type: "submit", disabled: t, children: "Add Tag" })
] })
] });
}
}
) })
] }) })
] });
}
export {
T as AddEditTagPage
};
//# sourceMappingURL=index-B8KfpruN.js.map