-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(create): modal step to assign new board to organization (#1304)
* feat(api): get request for organizations * feat(api): update post request for boards to create a private board or organization board * feat(create): add organization step to the modal * feat(create): component with dropdown to assign board to an organization * feat(create): clearable organizations dropdown * chore(create): cleanup organization step
- Loading branch information
1 parent
332a1e7
commit 73fbe6f
Showing
11 changed files
with
152 additions
and
27 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
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
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
44 changes: 44 additions & 0 deletions
44
next-tavla/src/Admin/scenarios/CreateBoard/components/AddToOrganization.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,44 @@ | ||
import { Button } from '@entur/button' | ||
import { Heading3, Paragraph } from '@entur/typography' | ||
import { TBoard } from 'types/settings' | ||
import { CreateBoardButton } from './CreateBoardButton' | ||
import { Dropdown } from '@entur/dropdown' | ||
import { useOrganizations } from '../hooks/useOrganizations' | ||
|
||
export function AddToOrganization({ | ||
board, | ||
popPage, | ||
}: { | ||
board: TBoard | ||
popPage: () => void | ||
}) { | ||
const { organizations, selectedOrganization, setSelectedOrganization } = | ||
useOrganizations() | ||
|
||
return ( | ||
<div className="flexColumn w-50"> | ||
<Heading3>Vil du legge tavla til i en organisasjon? </Heading3> | ||
<Paragraph> | ||
Hvis du ikke velger en organisasjon, vil tavla bli lagret under | ||
din private bruker. Det er kun du som kan administrere tavla som | ||
opprettes. | ||
</Paragraph> | ||
<Dropdown | ||
items={organizations} | ||
label="Dine organisasjoner" | ||
selectedItem={selectedOrganization} | ||
onChange={setSelectedOrganization} | ||
clearable | ||
/> | ||
<div className="flexRow justifyBetween mt-2"> | ||
<Button variant="secondary" onClick={popPage}> | ||
Tilbake | ||
</Button> | ||
<CreateBoardButton | ||
board={board} | ||
oid={selectedOrganization?.value} | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} |
18 changes: 9 additions & 9 deletions
18
next-tavla/src/Admin/scenarios/CreateBoard/components/CreateBoardButton.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
24 changes: 24 additions & 0 deletions
24
next-tavla/src/Admin/scenarios/CreateBoard/hooks/useOrganizations.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,24 @@ | ||
import { NormalizedDropdownItemType } from '@entur/dropdown' | ||
import { getOrganizationsForUserRequest } from 'Admin/utils/fetch' | ||
import { useCallback, useEffect, useState } from 'react' | ||
|
||
function useOrganizations() { | ||
const [organizationList, setOrganizationList] = useState< | ||
NormalizedDropdownItemType[] | ||
>([]) | ||
const [selectedOrganization, setSelectedOrganization] = | ||
useState<NormalizedDropdownItemType | null>(null) | ||
|
||
useEffect(() => { | ||
getOrganizationsForUserRequest().then((res) => setOrganizationList(res)) | ||
}, []) | ||
|
||
const organizations = useCallback( | ||
() => organizationList, | ||
[organizationList], | ||
) | ||
|
||
return { organizations, selectedOrganization, setSelectedOrganization } | ||
} | ||
|
||
export { useOrganizations } |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
export type TCreatePage = 'name' | 'addStops' | ||
export type TCreatePage = 'name' | 'addStops' | 'organization' |
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
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