import React, { FC, useState } from "react"; import styled from "styled-components"; import { Flex } from "reflexbox/styled-components"; // import Checkbox from "../Checkbox"; import TextInput from "../TextInput"; import { fadeIn } from "../../helpers/animations"; interface Props { isAuthenticated: boolean; domain: string; setShortenerFormError: any; // TODO: types } const Wrapper = styled(Flex).attrs({ flexDirection: "column", alignSelf: "flex-start", justifyContent: "flex-start" })` position: absolute; top: 74px; left: 0; z-index: 2; @media only screen and (max-width: 448px) { width: 100%; top: 56px; } `; const InputWrapper = styled(Flex).attrs({ flexDirection: ["column", "row"], alignItems: ["flex-start", "center"] })` @media only screen and (max-width: 448px) { > * { margin-bottom: 16px; } } `; const Label = styled.label` font-size: 18px; margin-right: 16px; animation: ${fadeIn} 0.5s ease-out; @media only screen and (max-width: 448px) { font-size: 14px; margin-right: 8px; } `; const ShortenerOptions: FC = props => { const [customurl, setCustomurl] = useState(); const [password, setPassword] = useState(); const checkAuth = () => { if (!props.isAuthenticated) { props.setShortenerFormError( "Please login or sign up to use this feature." ); return false; } return true; }; const handleCustomUrl = e => { if (!checkAuth()) return; setCustomurl(e.target.value); }; const handlePassword = e => { if (!checkAuth()) return; setPassword(e.target.value); }; const customUrlInput = customurl && (
); const passwordInput = password && (
); return ( {/* */} {customUrlInput} {passwordInput} ); }; // TODO: see if needed // shouldComponentUpdate(nextProps, nextState) { // const { customurlCheckbox, passwordCheckbox } = state; // return ( // props.isAuthenticated !== nextProps.isAuthenticated || // customurlCheckbox !== nextState.customurlCheckbox || // props.domain !== nextProps.domain || // passwordCheckbox !== nextState.passwordCheckbox // ); // } export default ShortenerOptions;