Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { Fragment } from 'react';
import { Button, Form, FullGridSize, WebId } from "../../profile.style";
import { Input } from '@util-components';
import { useTranslation } from "react-i18next";

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";


Expand All @@ -18,9 +20,10 @@ export const FormUi = ({ onSubmit, formFields, mode, onCancel, onInputChange, up
return item.value || '';
}

const {t} = useTranslation();
return(
<Fragment>
<Form onSubmit={onSubmit}>
<Form onSubmit={(e) => onSubmit(e, t('profile.updateSuccess'))}>
{formFields &&
formFields.map(item => (
<Input
Expand All @@ -37,6 +40,8 @@ export const FormUi = ({ onSubmit, formFields, mode, onCancel, onInputChange, up
data-label={item.label}
data-icon={item.icon}
type={'text'}
onInvalid={(e) => e.target.setCustomValidity(t('profile.nameRequired'))}
onInput={(e) => e.target.setCustomValidity('')}
/>
))}
<FullGridSize>
Expand All @@ -47,13 +52,13 @@ export const FormUi = ({ onSubmit, formFields, mode, onCancel, onInputChange, up
onClick={onCancel}
className='ids-link-stroke ids-link-stroke--primary'
>
Cancel
{t('profile.cancelBtn')}
</Button>
<Button
type='submit'
className='ids-link-filled ids-link-filled--primary'
>
Save
{t('profile.saveBtn')}
</Button>
</>
)}
Expand All @@ -69,4 +74,4 @@ export const FormUi = ({ onSubmit, formFields, mode, onCancel, onInputChange, up
)}
</Fragment>
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class ProfileForm extends Component {
* onSubmit will send all the updated fields to POD
* fields that was not updated will be not send it.
*/
onSubmit = async (e: Event) => {
onSubmit = async (e: Event, successMessage: String) => {
try {
e.preventDefault ();
let node;
Expand Down Expand Up @@ -137,11 +137,10 @@ export class ProfileForm extends Component {
this.setState ({
formFields: updatedFormField,
updatedFields: {},
formMode: true,
isLoading: false,
});

this.props.toastManager.add (['', 'Profile was updated successfully'], {
this.props.exitEditMode();
this.props.toastManager.add (['', successMessage], {
appearance: 'success',
});
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export const Image = ({ webId, toastManager, defaultProfilePhoto }: Props) => {
onComplete: uploadedFiles => {
updatePhoto(uploadedFiles[uploadedFiles.length - 1].uri)
},
render: props => <ImageProfile {...{ ...props, webId, photo: image || defaultProfilePhoto }} />
render: props => <ImageProfile {...{ ...props, webId, photo: image || defaultProfilePhoto, text: t('profile.upload'),
uploadingText: t('profile.uploadingText') }} />
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useState } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useTranslation } from "react-i18next";

import { withToastManager } from 'react-toast-notifications';
import { LiveUpdate, useWebId } from '@inrupt/solid-react-components';
import { Header, ProfileContainer, ProfileWrapper } from './profile.style';
Expand All @@ -23,6 +25,10 @@ const Profile = ({ toastManager }) => {
setMode(!mode);
};

const exitEditMode = () => {
setMode(true);
};
const { t } = useTranslation();
return (
<ProfileWrapper data-testid="profile-component">
<ProfileContainer>
Expand All @@ -36,7 +42,7 @@ const Profile = ({ toastManager }) => {
onClick={onCancel}
data-testid="edit-profile-button"
>
<FontAwesomeIcon icon="pencil-alt" /> EDIT
<FontAwesomeIcon icon="pencil-alt" /> {t('profile.edit')}
</button>
)}
<Image
Expand All @@ -47,7 +53,7 @@ const Profile = ({ toastManager }) => {
}}
/>
</Header>
<Form {...{ mode, toastManager, webId, onCancel }} />
<Form {...{ mode, toastManager, webId, onCancel, exitEditMode }} />
</LiveUpdate>
)}
</ProfileContainer>
Expand Down