From 0e741c6de029b6d956e2e6f18d1e2f314906e2fe Mon Sep 17 00:00:00 2001 From: name Date: Fri, 9 Sep 2022 19:40:29 -0700 Subject: [PATCH 1/3] deploy --- .../src/components/AccountTab/AccountTab.js | 93 +++++++++---------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/template/src/components/AccountTab/AccountTab.js b/template/src/components/AccountTab/AccountTab.js index 65dc34a0..4ed3f97c 100644 --- a/template/src/components/AccountTab/AccountTab.js +++ b/template/src/components/AccountTab/AccountTab.js @@ -1,4 +1,4 @@ -import React, { Component } from "react"; +import React, { useState, useEffect } from "react"; import PropTypes from "prop-types"; @@ -102,14 +102,35 @@ const initialState = { errors: null, }; -class AccountTab extends Component { - constructor(props) { - super(props); +function AccountTab() { - this.state = initialState; - } + const [initialState, useInitialState] = useState(""); - getNameInitialsOrIcon = () => { + useEffect(() => { + const { user, userData } = this.props; + + this.setState({ + profileCompletion: authentication.getProfileCompletion({ + ...user, + ...userData, + }), + securityRating: authentication.getSecurityRating(user, userData), + }); + }) + + useEffect(() => { + const { avatarUrl } = this.state; + + if (avatarUrl) { + URL.revokeObjectURL(avatarUrl); + + this.setState({ + avatarUrl: "", + }); + } + }) + + const getNameInitialsOrIcon = () => { const { user } = this.props; if (!user) { @@ -138,7 +159,7 @@ class AccountTab extends Component { return ; }; - uploadAvatar = () => { + const uploadAvatar = () => { const { avatar } = this.state; if (!avatar) { @@ -185,7 +206,7 @@ class AccountTab extends Component { ); }; - removeAvatar = () => { + const removeAvatar = () => { const { user } = this.props; const { avatar, avatarUrl } = this.state; @@ -244,7 +265,7 @@ class AccountTab extends Component { } }; - showField = (fieldId) => { + const showField = (fieldId) => { if (!fieldId) { return; } @@ -254,7 +275,7 @@ class AccountTab extends Component { }); }; - hideFields = (callback) => { + const hideFields = (callback) => { this.setState( { showingField: "", @@ -272,7 +293,7 @@ class AccountTab extends Component { ); }; - changeFirstName = () => { + const changeFirstName = () => { const { firstName } = this.state; const errors = validate( @@ -346,7 +367,7 @@ class AccountTab extends Component { ); }; - changeLastName = () => { + const changeLastName = () => { const { lastName } = this.state; const errors = validate( @@ -420,7 +441,7 @@ class AccountTab extends Component { ); }; - changeUsername = () => { + const changeUsername = () => { const { username } = this.state; const errors = validate( @@ -494,7 +515,7 @@ class AccountTab extends Component { ); }; - changeEmailAddress = () => { + const changeEmailAddress = () => { const { emailAddress } = this.state; const errors = validate( @@ -568,7 +589,7 @@ class AccountTab extends Component { ); }; - verifyEmailAddress = () => { + const verifyEmailAddress = () => { this.setState( { performingAction: true, @@ -605,7 +626,7 @@ class AccountTab extends Component { ); }; - changeField = (fieldId) => { + const changeField = (fieldId) => { switch (fieldId) { case "first-name": this.changeFirstName(); @@ -628,7 +649,7 @@ class AccountTab extends Component { } }; - handleKeyDown = (event, fieldId) => { + const handleKeyDown = (event, fieldId) => { if (!event || !fieldId) { return; } @@ -650,7 +671,7 @@ class AccountTab extends Component { } }; - handleAvatarChange = (event) => { + const handleAvatarChange = (event) => { if (!event) { return; } @@ -683,7 +704,7 @@ class AccountTab extends Component { }); }; - handleFirstNameChange = (event) => { + const handleFirstNameChange = (event) => { if (!event) { return; } @@ -695,7 +716,7 @@ class AccountTab extends Component { }); }; - handleLastNameChange = (event) => { + const handleLastNameChange = (event) => { if (!event) { return; } @@ -707,7 +728,7 @@ class AccountTab extends Component { }); }; - handleUsernameChange = (event) => { + const handleUsernameChange = (event) => { if (!event) { return; } @@ -719,7 +740,7 @@ class AccountTab extends Component { }); }; - handleEmailAddressChange = (event) => { + const handleEmailAddressChange = (event) => { if (!event) { return; } @@ -731,7 +752,6 @@ class AccountTab extends Component { }); }; - render() { // Styling const { classes } = this.props; @@ -1618,31 +1638,6 @@ class AccountTab extends Component { ); - } - - componentDidMount() { - const { user, userData } = this.props; - - this.setState({ - profileCompletion: authentication.getProfileCompletion({ - ...user, - ...userData, - }), - securityRating: authentication.getSecurityRating(user, userData), - }); - } - - componentWillUnmount() { - const { avatarUrl } = this.state; - - if (avatarUrl) { - URL.revokeObjectURL(avatarUrl); - - this.setState({ - avatarUrl: "", - }); - } - } } AccountTab.propTypes = { From caf9349a97b4dcd9a783d7cd286a7b3281bb701f Mon Sep 17 00:00:00 2001 From: name Date: Tue, 4 Oct 2022 08:13:56 -0700 Subject: [PATCH 2/3] class-to-hook-adminpage --- template/src/components/AdminPage/AdminPage.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/template/src/components/AdminPage/AdminPage.js b/template/src/components/AdminPage/AdminPage.js index 8f7269b6..b0038fde 100644 --- a/template/src/components/AdminPage/AdminPage.js +++ b/template/src/components/AdminPage/AdminPage.js @@ -1,11 +1,11 @@ -import React, { Component } from "react"; +import React from "react"; -import EmptyState from "../EmptyState"; +import EmptyState from '../EmptyState'; -class AdminPage extends Component { - render() { - return ; - } +function AdminPage() { + return ( + + ) } -export default AdminPage; +export default AdminPage; From 3c51e045f59e7f6b2c9b78748a1d9598e4f63ac7 Mon Sep 17 00:00:00 2001 From: name Date: Tue, 4 Oct 2022 08:25:56 -0700 Subject: [PATCH 3/3] class-to-hook-alertdialog --- .../src/components/AlertDialog/AlertDialog.js | 119 +++++++++--------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/template/src/components/AlertDialog/AlertDialog.js b/template/src/components/AlertDialog/AlertDialog.js index d1b2e5df..a500c2c1 100644 --- a/template/src/components/AlertDialog/AlertDialog.js +++ b/template/src/components/AlertDialog/AlertDialog.js @@ -1,70 +1,67 @@ -import React, { Component } from "react"; - -import PropTypes from "prop-types"; - -import { withStyles } from "@material-ui/core/styles"; - -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, -} from "@material-ui/core"; - -const styles = (theme) => ({ +import React from "react"; +import PropTypes from "prop-types"; +import { withStyles } from "@material-ui/core/styles"; + +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, +} from "@material-ui/core"; + +const styles = theme => ({ noTitlePadding: { - paddingTop: theme.spacing(3), - }, -}); - -class AlertDialog extends Component { - render() { - // Styling - const { classes } = this.props; - - // Dialog Properties - const { dialogProps } = this.props; - - // Custom Properties - const { - title, - contentText, - dismissiveAction, - confirmingAction, - acknowledgementAction, - } = this.props; - - if ((dismissiveAction || confirmingAction) && acknowledgementAction) { - console.error( - "Dialogs should contain a maximum of two actions. " + - "If a single action is provided, it must be an acknowledgement action. " + - "If two actions are provided, one must be a confirming action, and the other a dismissing action. " + - "Providing a third action such as “Learn more” is not recommended as it navigates the user away from the dialog, leaving the dialog task unfinished. " + - "https://material.io/design/components/dialogs.html#actions" - ); + paddingTop: theme.spacing(3), + }, +}); + +function AlertDialog() { + + //Styling + const { classes } = this.props; + + //Dialog Properties + const { dialogProps } = this.props; + + //Custom Properties + const { + title, + contentText, + dismissiveAction, + confirmAction, + acknowledgementAction, + } = this.props; + + if ((dismissiveAction || confirmAction) && acknowledgementAction) { + console.error( + "Dialogs should contain a maximum of two actions. " + + "If a single action is provided, it must be an acknowledgement action. " + + "If two actions are provided, one must be a confirming action, and the other a dismissing action. " + + "Providing a third action such as “Learn more” is not recommended as it navigates the user away from the dialog, leaving the dialog task unfinished. " + + "https://material.io/design/components/dialogs.html#actions" + ); - return null; - } + return null; + } - return ( - - {title && {title}} + return ( + + {title && {title}} - - {contentText} - + + {contentText} + - {(dismissiveAction || confirmingAction || acknowledgementAction) && ( - - {dismissiveAction} - {confirmingAction} - {acknowledgementAction} - + {(dismissiveAction || confirmAction || acknowledgementAction) && ( + + {dismissiveAction} + {confirmAction} + {acknowledgementAction} + )} - - ); - } + + ) } AlertDialog.propTypes = {