Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment out name inputs in user profile #1957

Merged
merged 4 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions packages/files-ui/cypress/tests/settings-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { navigationMenu } from "../support/page-objects/navigationMenu"
import { settingsPage } from "../support/page-objects/settingsPage"
import { homePage } from "../support/page-objects/homePage"
import { profileUpdateSuccessToast } from "../support/page-objects/toasts/profileUpdateSuccessToast"
// import { profileUpdateSuccessToast } from "../support/page-objects/toasts/profileUpdateSuccessToast"

describe("Settings", () => {
context("desktop", () => {
Expand All @@ -18,26 +18,26 @@ describe("Settings", () => {
settingsPage.profileTabHeader().should("be.visible")
})

it("save changes button should be disabled without first and last name", () => {
settingsPage.signOutDropdown().should("be.visible")
settingsPage.firstNameInput().clear()
settingsPage.lastNameInput().clear()
// it("save changes button should be disabled without first and last name", () => {
// settingsPage.signOutDropdown().should("be.visible")
// settingsPage.firstNameInput().clear()
// settingsPage.lastNameInput().clear()

settingsPage.saveChangesButton().should("be.disabled")
})
// settingsPage.saveChangesButton().should("be.disabled")
// })

it("can add/edit firstname and lastname", () => {
settingsPage.signOutDropdown().should("be.visible")
const newFirstName = "test first name"
const newLastName = "test last name"
// it("can add/edit firstname and lastname", () => {
// settingsPage.signOutDropdown().should("be.visible")
// const newFirstName = "test first name"
// const newLastName = "test last name"

settingsPage.firstNameInput().type(newFirstName)
settingsPage.lastNameInput().type(`${newLastName}{enter}`)
// settingsPage.firstNameInput().type(newFirstName)
// settingsPage.lastNameInput().type(`${newLastName}{enter}`)

profileUpdateSuccessToast.body().should("be.visible")
settingsPage.firstNameInput().should("have.value", newFirstName)
settingsPage.lastNameInput().should("have.value", newLastName)
})
// profileUpdateSuccessToast.body().should("be.visible")
// settingsPage.firstNameInput().should("have.value", newFirstName)
// settingsPage.lastNameInput().should("have.value", newLastName)
// })

// username from date
const newUserName = Date.now().toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { useState, useCallback, useMemo } from "react"
import * as yup from "yup"
import {
FormikTextInput,
Grid,
Button,
Typography,
Expand All @@ -13,13 +11,14 @@ import {
} from "@chainsafe/common-components"
import { makeStyles, createStyles, debounce } from "@chainsafe/common-theme"
import { CopyIcon } from "@chainsafe/common-components"
import { Form, useFormik, FormikProvider } from "formik"
import { useUser } from "../../../../Contexts/UserContext"
import { t, Trans } from "@lingui/macro"
import { centerEllipsis } from "../../../../Utils/Helpers"
import { CSFTheme } from "../../../../Themes/types"
import { useThresholdKey } from "../../../../Contexts/ThresholdKeyContext"
import EthCrypto from "eth-crypto"
// import { Form, useFormik, FormikProvider } from "formik"
// import * as yup from "yup"

const useStyles = makeStyles(({ constants, breakpoints, palette }: CSFTheme) =>
createStyles({
Expand Down Expand Up @@ -139,48 +138,48 @@ const useStyles = makeStyles(({ constants, breakpoints, palette }: CSFTheme) =>
})
)

const profileValidation = yup.object().shape({
// email: yup.string().email("Email is invalid").required("Email is required"),
firstName: yup.string(),
lastName: yup.string(),
username: yup.string()
})
// const profileValidation = yup.object().shape({
// email: yup.string().email("Email is invalid").required("Email is required"),
// firstName: yup.string(),
// lastName: yup.string(),
// username: yup.string()
// })

const ProfileView = () => {
const { addToast } = useToasts()
const { profile, updateProfile, addUsername, lookupOnUsername, toggleLookupConsent } = useUser()
const { profile, addUsername, lookupOnUsername, toggleLookupConsent } = useUser()
const { publicKey } = useThresholdKey()
const [updatingProfile, setUpdatingProfile] = useState(false)
const [showUsernameForm, setShowUsernameForm] = useState(false)
const [username, setUsername] = useState("")
const [usernameData, setUsernameData] = useState({ error: "", loading: false })
const formik = useFormik({
initialValues: {
firstName: profile?.firstName || "",
lastName: profile?.lastName || ""
// email: profile?.email || ""
},
onSubmit: (values) => {
onUpdateProfile(
values.firstName || "",
values.lastName || ""
// values.email || ""
)
},
validationSchema: profileValidation,
validateOnChange: false
})
const onUpdateProfile = async (firstName: string, lastName: string) => {
try {
setUpdatingProfile(true)
await updateProfile(firstName, lastName)
addToast({ title: t`Profile updated`, type: "success", testId: "profile-update-success" })
setUpdatingProfile(false)
} catch (error) {
error instanceof Error && addToast({ title: error.message, type: "error" })
setUpdatingProfile(false)
}
}
// const [updatingProfile, setUpdatingProfile] = useState(false)
// const formik = useFormik({
// initialValues: {
// firstName: profile?.firstName || "",
// lastName: profile?.lastName || ""
// email: profile?.email || ""
// },
// onSubmit: (values) => {
// onUpdateProfile(
// values.firstName || "",
// values.lastName || ""
// values.email || ""
// )
// },
// validationSchema: profileValidation,
// validateOnChange: false
// })
// const onUpdateProfile = async (firstName: string, lastName: string) => {
// try {
// setUpdatingProfile(true)
// await updateProfile(firstName, lastName)
// addToast({ title: t`Profile updated`, type: "success", testId: "profile-update-success" })
// setUpdatingProfile(false)
// } catch (error) {
// error instanceof Error && addToast({ title: error.message, type: "error" })
// setUpdatingProfile(false)
// }
// }

const classes = useStyles()

Expand Down Expand Up @@ -451,7 +450,7 @@ const ProfileView = () => {
value={profile?.lookupConsent || false}
onChange={toggleLookupConsent} />
</div>
<FormikProvider value={formik}>
{/* <FormikProvider value={formik}>
<Form>
<div className={classes.inputBoxContainer}>
<Typography
Expand Down Expand Up @@ -493,7 +492,7 @@ const ProfileView = () => {
data-cy="input-profile-lastname"
/>
</div>
{/* <div className={classes.boxContainer}>
<div className={classes.boxContainer}>
<FormikTextInput
placeholder="Email"
name="email"
Expand All @@ -503,7 +502,7 @@ const ProfileView = () => {
label="Email"
disabled={!profile?.publicAddress}
/>
</div> */}
</div>
<Button
className={classes.button}
size="large"
Expand All @@ -519,7 +518,7 @@ const ProfileView = () => {
</Typography>
</Button>
</Form>
</FormikProvider>
</FormikProvider> */}
</div>
</div>
{/* <div id="deletion" className={classes.sectionContainer}>
Expand Down
15 changes: 0 additions & 15 deletions packages/files-ui/src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,6 @@ msgstr "Dateien"
msgid "Files sharing key"
msgstr "Dateifreigabeschlüssel"

msgid "First name"
msgstr "Vorname"

msgid "Folder name is already in use"
msgstr ""

Expand Down Expand Up @@ -496,9 +493,6 @@ msgstr ""
msgid "Language"
msgstr "Sprache"

msgid "Last name"
msgstr "Nachname"

msgid "Learn more"
msgstr "Mehr erfahren"

Expand Down Expand Up @@ -616,9 +610,6 @@ msgstr ""
msgid "Only send the exact amount of {0} to this address"
msgstr ""

msgid "Only you can see this."
msgstr "Nur Sie können dies sehen."

msgid "Oops! You need to pay for this month to upload more content."
msgstr ""

Expand Down Expand Up @@ -718,9 +709,6 @@ msgstr ""
msgid "Profile"
msgstr ""

msgid "Profile updated"
msgstr "Profil aktualisiert"

msgid "Recover"
msgstr "Wiederherstellen"

Expand Down Expand Up @@ -772,9 +760,6 @@ msgstr "Ressourcen"
msgid "Restore with backup secret phrase"
msgstr "Mit Sicherungsgeheimsatz wiederherstellen"

msgid "Save changes"
msgstr "Änderungen speichern"

msgid "Save this browser for next time?"
msgstr "Diesen Browser für das nächste Mal speichern?"

Expand Down
15 changes: 0 additions & 15 deletions packages/files-ui/src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,6 @@ msgstr "Files"
msgid "Files sharing key"
msgstr "Files sharing key"

msgid "First name"
msgstr "First name"

msgid "Folder name is already in use"
msgstr "Folder name is already in use"

Expand Down Expand Up @@ -499,9 +496,6 @@ msgstr "Keep original files"
msgid "Language"
msgstr "Language"

msgid "Last name"
msgstr "Last name"

msgid "Learn more"
msgstr "Learn more"

Expand Down Expand Up @@ -619,9 +613,6 @@ msgstr "One sec, getting files ready…"
msgid "Only send the exact amount of {0} to this address"
msgstr "Only send the exact amount of {0} to this address"

msgid "Only you can see this."
msgstr "Only you can see this."

msgid "Oops! You need to pay for this month to upload more content."
msgstr "Oops! You need to pay for this month to upload more content."

Expand Down Expand Up @@ -721,9 +712,6 @@ msgstr "Proceed to payment"
msgid "Profile"
msgstr "Profile"

msgid "Profile updated"
msgstr "Profile updated"

msgid "Recover"
msgstr "Recover"

Expand Down Expand Up @@ -775,9 +763,6 @@ msgstr "Resources"
msgid "Restore with backup secret phrase"
msgstr "Restore with backup secret phrase"

msgid "Save changes"
msgstr "Save changes"

msgid "Save this browser for next time?"
msgstr "Save this browser for next time?"

Expand Down
15 changes: 0 additions & 15 deletions packages/files-ui/src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,6 @@ msgstr "Archivos"
msgid "Files sharing key"
msgstr ""

msgid "First name"
msgstr "Primer Nombre"

msgid "Folder name is already in use"
msgstr ""

Expand Down Expand Up @@ -500,9 +497,6 @@ msgstr ""
msgid "Language"
msgstr "Idioma"

msgid "Last name"
msgstr "Apellido"

msgid "Learn more"
msgstr "Aprende Mas"

Expand Down Expand Up @@ -620,9 +614,6 @@ msgstr ""
msgid "Only send the exact amount of {0} to this address"
msgstr ""

msgid "Only you can see this."
msgstr ""

msgid "Oops! You need to pay for this month to upload more content."
msgstr ""

Expand Down Expand Up @@ -722,9 +713,6 @@ msgstr ""
msgid "Profile"
msgstr ""

msgid "Profile updated"
msgstr "Perfil actualizado"

msgid "Recover"
msgstr "Recuperar"

Expand Down Expand Up @@ -776,9 +764,6 @@ msgstr "Recursos"
msgid "Restore with backup secret phrase"
msgstr ""

msgid "Save changes"
msgstr "Guardar cambios"

msgid "Save this browser for next time?"
msgstr "Guardar este navegador para la próxima vez?"

Expand Down
15 changes: 0 additions & 15 deletions packages/files-ui/src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,6 @@ msgstr "Fichiers"
msgid "Files sharing key"
msgstr "Clé de partage des fichiers"

msgid "First name"
msgstr "Prénom"

msgid "Folder name is already in use"
msgstr "Le nom du dossier est déjà utilisé"

Expand Down Expand Up @@ -500,9 +497,6 @@ msgstr "Conserver les fichiers originaux"
msgid "Language"
msgstr "Langue"

msgid "Last name"
msgstr "Nom"

msgid "Learn more"
msgstr "En savoir plus"

Expand Down Expand Up @@ -620,9 +614,6 @@ msgstr "Les fichiers sont presque prêts…"
msgid "Only send the exact amount of {0} to this address"
msgstr "N'envoyez que la somme exacte de {0} à cette adresse"

msgid "Only you can see this."
msgstr "Vous seul(e) pouvez voir ceci."

msgid "Oops! You need to pay for this month to upload more content."
msgstr "Oups ! Vous devez payer pour ce mois-ci pour ajouter plus de contenu."

Expand Down Expand Up @@ -722,9 +713,6 @@ msgstr "Procéder au paiement"
msgid "Profile"
msgstr "Profil"

msgid "Profile updated"
msgstr "Profile mis à jour"

msgid "Recover"
msgstr "Récupérer"

Expand Down Expand Up @@ -776,9 +764,6 @@ msgstr "Ressources"
msgid "Restore with backup secret phrase"
msgstr "Récupérer avec la phrase de sauvegarde secrète"

msgid "Save changes"
msgstr "Enregistrer"

msgid "Save this browser for next time?"
msgstr "Enregistrer ce navigateur ?"

Expand Down
Loading