-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3359 from navikt/feature/flytt-person-alle-grupper
Feature/flytt person alle grupper
- Loading branch information
Showing
15 changed files
with
143 additions
and
41 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
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
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
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
71 changes: 71 additions & 0 deletions
71
apps/dolly-frontend/src/main/js/src/components/velgGruppe/AlleGrupper.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,71 @@ | ||
import { DollySelect } from '@/components/ui/form/inputs/select/Select' | ||
import Loading from '@/components/ui/loading/Loading' | ||
import { useAlleBrukere, useCurrentBruker } from '@/utils/hooks/useBruker' | ||
import { Gruppe, useEgneGrupper, useGrupper } from '@/utils/hooks/useGruppe' | ||
import React, { useState } from 'react' | ||
|
||
interface AlleGrupper { | ||
setValgtGruppe: React.Dispatch<React.SetStateAction<string>> | ||
valgtGruppe: string | ||
fraGruppe?: number | null | ||
} | ||
|
||
type Options = { | ||
value: string | ||
label: string | ||
} | ||
|
||
export default ({ setValgtGruppe, valgtGruppe, fraGruppe = null }: AlleGrupper) => { | ||
const { currentBruker } = useCurrentBruker() | ||
const { brukere, loading: loadingBrukere } = useAlleBrukere() | ||
const [valgtBruker, setValgtBruker] = useState(null) | ||
|
||
const filteredBrukerliste = brukere?.filter( | ||
(bruker) => bruker.brukerId !== currentBruker.brukerId, | ||
) | ||
|
||
const brukerOptions = filteredBrukerliste?.map((bruker) => { | ||
return { | ||
value: bruker?.brukerId, | ||
label: bruker?.brukernavn, | ||
} | ||
}) | ||
|
||
const { grupper, loading: loadingGrupper } = useEgneGrupper(valgtBruker) | ||
|
||
const filteredGruppeliste = grupper?.contents?.filter((gruppe) => gruppe.id !== fraGruppe) | ||
|
||
const gruppeOptions = filteredGruppeliste?.map((gruppe: Gruppe) => { | ||
return { | ||
value: gruppe.id, | ||
label: `${gruppe.id} - ${gruppe.navn}`, | ||
} | ||
}) | ||
|
||
return ( | ||
<div className="flexbox--flex-wrap"> | ||
<DollySelect | ||
name={'Bruker'} | ||
label={'Bruker'} | ||
options={brukerOptions} | ||
size="medium" | ||
onChange={(bruker) => setValgtBruker(bruker?.value || null)} | ||
value={valgtBruker} | ||
isLoading={loadingBrukere} | ||
placeholder={loadingBrukere ? 'Laster brukere ...' : 'Velg bruker ...'} | ||
/> | ||
<DollySelect | ||
name="Gruppe" | ||
label="Gruppe" | ||
options={gruppeOptions} | ||
onChange={(gruppe: Options) => setValgtGruppe(gruppe?.value)} | ||
value={valgtGruppe} | ||
size={fraGruppe ? 'grow' : 'large'} | ||
isClearable={false} | ||
isDisabled={!valgtBruker} | ||
isLoading={loadingGrupper} | ||
placeholder={loadingGrupper ? 'Laster grupper ...' : 'Velg gruppe ...'} | ||
/> | ||
</div> | ||
) | ||
} |
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
Oops, something went wrong.