-
Notifications
You must be signed in to change notification settings - Fork 169
[frontend] Translation user's files from javascript to typescript #4290
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fe0fca5
[frontend] Translate User's files from javascript to typescript
camrrx 43b1ef9
Merge branch 'release/current' into issue/translation-user-typescript
camrrx 854f79c
[frontend] Translate User's files from javascript to typescript
camrrx 66af532
[frontend] Translate User's files from javascript to typescript
camrrx 2571989
Merge branch 'release/current' into issue/translation-user-typescript
camrrx 229029c
[frontend] Translate User's files from javascript to typescript
camrrx c9e2108
[frontend] Translate User's files from javascript to typescript
camrrx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
4 changes: 2 additions & 2 deletions
4
openaev-front/src/actions/User.js → openaev-front/src/actions/users/User.js
This file contains hidden or 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
This file contains hidden or 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,15 @@ | ||
| import type { Option } from '../../../../utils/Option'; | ||
| import { type UpdateUserInput } from '../../utils/api-types'; | ||
|
|
||
| export type UserInputForm = Omit< | ||
| UpdateUserInput, | ||
| 'user_organization' | 'user_tags' | ||
| > & { | ||
| user_organization: Option | undefined; | ||
| user_tags: Option[]; | ||
| }; | ||
|
|
||
| export interface UserResult { | ||
| entities: { users: Record<string, User> }; | ||
| result: string; | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
101 changes: 0 additions & 101 deletions
101
openaev-front/src/admin/components/settings/users/CreateUser.js
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
openaev-front/src/admin/components/settings/users/CreateUser.tsx
This file contains hidden or 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,79 @@ | ||
| import { useState } from 'react'; | ||
|
|
||
| import type { OrganizationHelper } from '../../../../actions/helper'; | ||
| import { addUser } from '../../../../actions/users/User'; | ||
| import { type UserInputForm, type UserResult } from '../../../../actions/users/users-helper'; | ||
| import ButtonCreate from '../../../../components/common/ButtonCreate'; | ||
| import Drawer from '../../../../components/common/Drawer'; | ||
| import { useFormatter } from '../../../../components/i18n'; | ||
| import { useHelper } from '../../../../store'; | ||
| import { type User } from '../../../../utils/api-types'; | ||
| import { useAppDispatch } from '../../../../utils/hooks'; | ||
| import { type Option } from '../../../../utils/Option'; | ||
| import UserForm from './UserForm'; | ||
|
|
||
| interface CreateUserProps { onCreate?: (user: User) => void } | ||
|
|
||
| const CreateUser = ({ onCreate }: CreateUserProps) => { | ||
| const { t } = useFormatter(); | ||
| const dispatch = useAppDispatch(); | ||
|
|
||
| const [open, setOpen] = useState(false); | ||
|
|
||
| const handleOpen = () => setOpen(true); | ||
| const handleClose = () => setOpen(false); | ||
|
|
||
| const { organizationsMap } = useHelper( | ||
| ( | ||
| helper: OrganizationHelper, | ||
| ) => { | ||
| return { organizationsMap: helper.getOrganizationsMap() }; | ||
| }, | ||
| ); | ||
| const onSubmit = (data: UserInputForm) => { | ||
| const inputValues = { | ||
| ...data, | ||
| user_organization: data.user_organization?.id, | ||
| user_tags: data.user_tags?.map((tag: Option) => tag.id), | ||
| }; | ||
|
|
||
| return dispatch(addUser(inputValues)).then((result: UserResult) => { | ||
| if (result?.entities?.users && onCreate) { | ||
| const userCreated = result.entities.users[result.result]; | ||
|
|
||
| const orgId = userCreated.user_organization; | ||
| const org = orgId ? organizationsMap[orgId] : undefined; | ||
|
|
||
| const userToCreate = { | ||
| ...userCreated, | ||
| user_organization_name: org ? org.organization_name : '', | ||
| user_organization_id: org ? org.organization_id : '', | ||
| }; | ||
|
|
||
| onCreate(userToCreate); | ||
| } | ||
| return result.result ? handleClose() : result; | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <ButtonCreate onClick={handleOpen} style={{ right: 230 }} /> | ||
|
|
||
| <Drawer | ||
| open={open} | ||
| handleClose={handleClose} | ||
| title={t('Create a new user')} | ||
| > | ||
| <UserForm | ||
| editing={false} | ||
| onSubmit={onSubmit} | ||
| handleClose={handleClose} | ||
| initialValues={{ user_tags: [] }} | ||
| /> | ||
| </Drawer> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default CreateUser; | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.