From 1519c913241669b532d13351331e7a8d512e1438 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Fri, 17 Jul 2020 22:29:38 -0700 Subject: refactor renderers --- frontend/src/components/modals/PasswordModal.js | 72 +++++++++++-------------- 1 file changed, 31 insertions(+), 41 deletions(-) (limited to 'frontend/src/components/modals/PasswordModal.js') diff --git a/frontend/src/components/modals/PasswordModal.js b/frontend/src/components/modals/PasswordModal.js index 527fc54..e250e84 100644 --- a/frontend/src/components/modals/PasswordModal.js +++ b/frontend/src/components/modals/PasswordModal.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useRef } from 'react'; import Modal from 'react-modal'; import { PassInput } from '../Inputs' import { RightPad, LeftPad, ModalHeader, Padding } from './shared' @@ -15,49 +15,39 @@ const modalStyles = { } }; -class PasswordModal extends React.Component { +const PasswordModal = (props) => { + const ErrorLabel = useRef(); + Modal.setAppElement('body'); - componentWillMount() { - Modal.setAppElement('body'); + function submitPassword(e) { + e.preventDefault(); + const password = props.value + props.validateCallback(password, ErrorLabel.current.showMessage) } - constructor(props) { - super(props); - this.submitPassword = this.submitPassword.bind(this); - this.ErrorLabel = React.createRef(); - } - - submitPassword(event) { - const password = this.props.value - this.props.validateCallback(password) - event.preventDefault(); - } - - render() { - return( - -
- - 🚧 err: password protected - - - - - - - - - -
-
- ); - } + return( + +
+ + 🚧 err: password protected + + + + + + + + + +
+
+ ); } export default PasswordModal \ No newline at end of file -- cgit v1.2.3 From 4916fec43a8fae28c7d0c230505d5c4c2ac2f026 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sat, 18 Jul 2020 15:34:26 -0700 Subject: refactor viewpaste and fixed button height --- frontend/src/components/modals/PasswordModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frontend/src/components/modals/PasswordModal.js') diff --git a/frontend/src/components/modals/PasswordModal.js b/frontend/src/components/modals/PasswordModal.js index e250e84..bf373cc 100644 --- a/frontend/src/components/modals/PasswordModal.js +++ b/frontend/src/components/modals/PasswordModal.js @@ -16,7 +16,7 @@ const modalStyles = { }; const PasswordModal = (props) => { - const ErrorLabel = useRef(); + const ErrorLabel = useRef(null); Modal.setAppElement('body'); function submitPassword(e) { -- cgit v1.2.3