import { ImagePicker } from "../ImagePicker";
import { Reminder } from "../../../api";

type Props = {
    name: string;
    icon: string;
    setReminder: (r: (reminder: Reminder) => Reminder) => void;
};

export const Author = ({ name, icon, setReminder }: Props) => {
    return (
        <div class="embed-author-box">
            <div class="a">
                <p class="image is-24x24 customizable">
                    <ImagePicker
                        class="is-rounded embed_author_url"
                        url={icon}
                        alt="Image for embed author"
                        setImage={(url: string) => {
                            setReminder((reminder) => ({
                                ...reminder,
                                embed_author_url: url,
                            }));
                        }}
                    ></ImagePicker>
                </p>
            </div>

            <div class="b">
                <label class="is-sr-only" for="embedAuthor">
                    Embed Author
                </label>
                <textarea
                    class="discord-embed-author message-input autoresize"
                    placeholder="Embed Author..."
                    rows={1}
                    maxlength={256}
                    name="embed_author"
                    value={name}
                    onInput={(ev) => {
                        setReminder((reminder) => ({
                            ...reminder,
                            embed_author: ev.currentTarget.value,
                        }));
                    }}
                ></textarea>
            </div>
        </div>
    );
};
