-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e0f05c
commit a16ee71
Showing
37 changed files
with
1,846 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
web-app/client/src/graphql/operations/mutations/updateUser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
export const UPDATE_USER = gql` | ||
mutation updateUser($props: UpdatingUserProps!) { | ||
updateUser(props: $props) { | ||
message | ||
} | ||
} | ||
`; |
35 changes: 35 additions & 0 deletions
35
web-app/client/src/graphql/operations/queries/getOwnDatasets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
export const GET_OWN_DATASETS = gql` | ||
query getOwnDatasets( | ||
$filter: DatasetsFilter | ||
$sort: DatasetsSort | ||
$pagination: Pagination | ||
) { | ||
user { | ||
datasets(filter: $filter, sort: $sort, pagination: $pagination) { | ||
total | ||
data { | ||
fileID | ||
fileName | ||
hasHeader | ||
delimiter | ||
supportedPrimitives | ||
rowsCount | ||
fileSize | ||
fileFormat { | ||
inputFormat | ||
tidColumnIndex | ||
itemColumnIndex | ||
hasTid | ||
} | ||
countOfColumns | ||
isBuiltIn | ||
createdAt | ||
originalFileName | ||
numberOfUses | ||
} | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
web-app/client/src/routes/UserCabinet/tabs/AccountSettings/AccountSettings.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@import "styles/common"; | ||
|
||
.accountSettingsTab { | ||
max-width: 464px; | ||
|
||
.title { | ||
margin: 0 0 32px; | ||
} | ||
|
||
.additionalActions { | ||
display: flex; | ||
gap: 16px; | ||
|
||
button { | ||
width: 100%; | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
web-app/client/src/routes/UserCabinet/tabs/AccountSettings/AccountSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { FC, useState } from 'react'; | ||
import { useQuery } from '@apollo/client'; | ||
import { GET_USER } from '@graphql/operations/queries/getUser'; | ||
import { getUser } from '@graphql/operations/queries/__generated__/getUser'; | ||
import ProfileForm from './components/ProfileForm'; | ||
import Button from '@components/Button'; | ||
import ChangePasswordModal from './components/ChangePasswordModal'; | ||
import styles from './AccountSettings.module.scss'; | ||
|
||
const AccountSettings: FC = () => { | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const { data } = useQuery<getUser>(GET_USER, { | ||
variables: { | ||
userID: undefined, | ||
}, | ||
}); | ||
|
||
const user = data?.user; | ||
|
||
if (!user) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className={styles.accountSettingsTab}> | ||
<h5 className={styles.title}>Account Settings</h5> | ||
<ProfileForm user={user} /> | ||
<div className={styles.additionalActions}> | ||
<Button variant="secondary" onClick={() => setIsModalOpen(true)}> | ||
Change Password | ||
</Button> | ||
<Button variant="secondary-danger" disabled> | ||
Delete Account | ||
</Button> | ||
</div> | ||
{isModalOpen && ( | ||
<ChangePasswordModal onClose={() => setIsModalOpen(false)} /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AccountSettings; |
21 changes: 21 additions & 0 deletions
21
...binet/tabs/AccountSettings/components/ChangePasswordModal/ChangePasswordModal.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@import "styles/common"; | ||
|
||
.changePasswordModal { | ||
.title { | ||
text-align: center; | ||
margin: 0 0 32px; | ||
} | ||
|
||
form { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 24px; | ||
margin: 0 0 32px; | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
justify-content: center; | ||
gap: 16px; | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
...s/UserCabinet/tabs/AccountSettings/components/ChangePasswordModal/ChangePasswordModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Text } from '@components/Inputs'; | ||
import ModalContainer, { ModalProps } from '@components/ModalContainer'; | ||
import { FC, useId } from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
import isStrongPassword from 'validator/lib/isStrongPassword'; | ||
import styles from './ChangePasswordModal.module.scss'; | ||
import Button from '@components/Button'; | ||
import { useMutation } from '@apollo/client'; | ||
import { CHANGE_PASSWORD } from '@graphql/operations/mutations/changePassword'; | ||
import { | ||
changePassword, | ||
changePasswordVariables, | ||
} from '@graphql/operations/mutations/__generated__/changePassword'; | ||
|
||
type Inputs = { | ||
oldPassword: string; | ||
newPassword: string; | ||
repeatPassword: string; | ||
}; | ||
|
||
const ChangePasswordModal: FC<ModalProps> = ({ onClose }) => { | ||
const { | ||
register, | ||
formState: { errors }, | ||
handleSubmit, | ||
} = useForm<Inputs>(); | ||
const formId = useId(); | ||
const [changePassword] = useMutation<changePassword, changePasswordVariables>( | ||
CHANGE_PASSWORD, | ||
); | ||
|
||
const onSubmit = handleSubmit(async (values) => { | ||
try { | ||
await changePassword({ | ||
variables: { | ||
currentPwdHash: values.oldPassword, | ||
newPwdHash: values.newPassword, | ||
}, | ||
}); | ||
location.reload(); | ||
} catch (e) {} | ||
}); | ||
|
||
return ( | ||
<ModalContainer onClose={onClose} className={styles.changePasswordModal}> | ||
<h4 className={styles.title}>Change password</h4> | ||
<form onSubmit={onSubmit} id={formId}> | ||
<Text | ||
label="Old password" | ||
type="password" | ||
placeholder="admin1234" | ||
{...register('oldPassword', { | ||
required: 'Required', | ||
})} | ||
error={errors.oldPassword?.message} | ||
/> | ||
<Text | ||
label="New password" | ||
type="password" | ||
placeholder="admin1234" | ||
{...register('newPassword', { | ||
required: 'Required', | ||
// validate: (value) => isStrongPassword(value) || 'Weak password', | ||
})} | ||
error={errors.newPassword?.message} | ||
/> | ||
<Text | ||
label="Repeat password" | ||
type="password" | ||
placeholder="admin1234" | ||
{...register('repeatPassword', { | ||
required: 'Required', | ||
validate: { | ||
// isStrong: (value) => isStrongPassword(value) || 'Weak password', | ||
isSame: (value, { newPassword }) => | ||
value === newPassword || 'Passwords do not match', | ||
}, | ||
})} | ||
error={errors.repeatPassword?.message} | ||
/> | ||
</form> | ||
<div className={styles.actions}> | ||
<Button variant="secondary">Cancel</Button> | ||
<Button type="submit" form={formId}> | ||
Update password | ||
</Button> | ||
</div> | ||
</ModalContainer> | ||
); | ||
}; | ||
|
||
export default ChangePasswordModal; |
1 change: 1 addition & 0 deletions
1
...lient/src/routes/UserCabinet/tabs/AccountSettings/components/ChangePasswordModal/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ChangePasswordModal'; |
8 changes: 8 additions & 0 deletions
8
...rc/routes/UserCabinet/tabs/AccountSettings/components/ProfileForm/ProfileForm.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@import "styles/common"; | ||
|
||
.profileForm { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 24px; | ||
margin: 0 0 16px; | ||
} |
Oops, something went wrong.