mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-12 17:28:31 +03:00
fix: forgot to update page (#938)
This commit is contained in:
@@ -1,27 +1,34 @@
|
||||
import React, { useState } from "react";
|
||||
import { Button, Form, InputGroup } from "react-bootstrap";
|
||||
import Icon from "./Icon";
|
||||
import Muted from "./Muted";
|
||||
|
||||
export default function EditableText({
|
||||
as = "p",
|
||||
onSubmit,
|
||||
initial,
|
||||
authorised,
|
||||
initialText,
|
||||
placeholderText,
|
||||
className,
|
||||
authorised,
|
||||
}: {
|
||||
as?: "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "span";
|
||||
onSubmit: (value: string) => void;
|
||||
initial: string;
|
||||
authorised: boolean;
|
||||
initialText: string;
|
||||
placeholderText: string;
|
||||
className?: string;
|
||||
authorised: boolean;
|
||||
}) {
|
||||
const [text, setText] = useState(initial);
|
||||
const [text, setText] = useState(initialText);
|
||||
const [editing, setEditing] = useState(false);
|
||||
|
||||
if (editing) {
|
||||
return (
|
||||
<InputGroup>
|
||||
<Form.Control value={text} onChange={(e) => setText(e.target.value)} />
|
||||
<Form.Control
|
||||
value={text}
|
||||
placeholder={placeholderText}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
variant="success"
|
||||
type="submit"
|
||||
@@ -41,7 +48,7 @@ export default function EditableText({
|
||||
onClick={() => authorised && setEditing(true)}
|
||||
className={`d-flex gap-2 ${authorised ? "cursor-pointer" : ""}`}
|
||||
>
|
||||
{React.createElement(as, { className }, text)}
|
||||
{React.createElement(as, { className }, text ? text : <Muted>{placeholderText}</Muted>)}
|
||||
{authorised && <Icon type="pencil-alt" />}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user