mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-05-24 19:44:13 +00:00
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>
59 lines
1.3 KiB
TypeScript
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;
|