chirpstack/ui/src/components/DeleteConfirm.tsx
SAGAR PATEL 2ea86b2ca2
Implement automatic formatting for JS / TSX source code.
Implemented automatic code formatting for JS/TSX using prettier and husky
with pre-commit hook

Signed-off-by: SAGAR PATEL <sagar.a.patel@slscorp.com>

Co-authored-by: Orne Brocaar <info@brocaar.com>
2022-05-02 10:58:26 +01:00

59 lines
1.3 KiB
TypeScript

import React, { Component } from "react";
import { Popover, Button, Typography, Space, Input } from "antd";
interface IProps {
typ: string;
confirm: string;
onConfirm: () => void;
}
interface ConfirmState {
confirm: string;
}
class DeleteConfirmContent extends Component<IProps, ConfirmState> {
constructor(props: IProps) {
super(props);
this.state = {
confirm: "",
};
}
onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.setState({
confirm: e.target.value,
});
};
render() {
return (
<Space direction="vertical">
<Typography.Text>
Enter '{this.props.confirm}' to confirm you want to delete this {this.props.typ}:
</Typography.Text>
<Input placeholder={this.props.confirm} onChange={this.onChange} />
<Button
onClick={this.props.onConfirm}
disabled={this.state.confirm !== this.props.confirm}
style={{ float: "right" }}
>
Delete
</Button>
</Space>
);
}
}
class DeleteConfirm extends Component<IProps> {
render() {
return (
<Popover content={<DeleteConfirmContent {...this.props} />} trigger="click" placement="left">
{this.props.children}
</Popover>
);
}
}
export default DeleteConfirm;