/* Copyright 2020 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React, { useEffect, useRef } from "react"; import Tile from "./Tile"; import Button from "./Button"; import TextButton from "./TextButton"; import Input from "./Input"; import { Formik, Form } from "formik"; import * as Yup from "yup"; import "./CreateLinkTile.scss"; interface ILinkNotCreatedTileProps { setLink: React.Dispatch>; } const LinkNotCreatedTile = (props: ILinkNotCreatedTileProps) => { return (

Create shareable links to Matrix rooms, users or messages without being tied to any app

link ) .required("Required"), })} onSubmit={(values) => { props.setLink( document.location.protocol + "//" + document.location.host + "/" + values.identifier ); }} >
); }; interface ILinkCreatedTileProps { link: string; setLink: React.Dispatch>; } const LinkCreatedTile: React.FC = (props) => { const buttonRef = useRef(null); // Focus button on render useEffect(() => { if (buttonRef && buttonRef.current) { buttonRef.current.focus(); } }); return ( props.setLink("")}> Create another lnk

{props.link}

); }; const CreateLinkTile: React.FC = () => { const [link, setLink] = React.useState(""); console.log(link); if (!link) { return ; } else { return ; } }; export default CreateLinkTile;