mirror of https://github.com/ctk-hq/ctk
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { useCallback } from "react";
|
|
import {
|
|
CallbackFunction,
|
|
IEditServiceForm,
|
|
IServiceNodeItem
|
|
} from "../../../../types";
|
|
import {
|
|
getFinalValues,
|
|
getInitialValues,
|
|
tabs,
|
|
validationSchema
|
|
} from "./form-utils";
|
|
import { toaster } from "../../../../utils";
|
|
import FormModal from "../../../FormModal";
|
|
|
|
interface IModalServiceProps {
|
|
onHide: CallbackFunction;
|
|
onAddEndpoint: CallbackFunction;
|
|
}
|
|
|
|
const CreateServiceModal = (props: IModalServiceProps) => {
|
|
const { onHide, onAddEndpoint } = props;
|
|
|
|
const handleCreate = useCallback(
|
|
(finalValues: IServiceNodeItem, values: IEditServiceForm) => {
|
|
onHide();
|
|
onAddEndpoint(finalValues);
|
|
toaster(
|
|
`Created "${values.serviceName}" service successfully`,
|
|
"success"
|
|
);
|
|
},
|
|
[onAddEndpoint, onHide]
|
|
);
|
|
|
|
return (
|
|
<FormModal
|
|
title="Services > New"
|
|
resourceType="service"
|
|
tabs={tabs}
|
|
items={["test"]}
|
|
getInitialValues={getInitialValues}
|
|
getFinalValues={getFinalValues}
|
|
getText={() => "test"}
|
|
validationSchema={validationSchema}
|
|
onHide={onHide}
|
|
onCreate={handleCreate}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default CreateServiceModal;
|