1
- import { DragAndDropContext } from '@app/components/documents/drag-context' ;
2
1
import { DeleteDropArea } from '@app/components/documents/new-documents/header/delete-drop-area' ;
3
- import { DropZone } from '@app/components/documents/new-documents/shared/drop-zone' ;
4
2
import { useIsExpanded } from '@app/components/documents/use-is-expanded' ;
5
- import { useOppgaveId } from '@app/hooks/oppgavebehandling/use-oppgave-id' ;
6
- import { useHasRole } from '@app/hooks/use-has-role' ;
7
- import { useIsSaksbehandler } from '@app/hooks/use-is-saksbehandler' ;
8
3
import { useValidationError } from '@app/hooks/use-validation-error' ;
9
- import { useSetParentMutation } from '@app/redux-api/oppgaver/mutations/documents' ;
10
- import { Role } from '@app/types/bruker' ;
11
- import { DocumentTypeEnum , type IMainDocument } from '@app/types/documents/documents' ;
12
- import { TemplateIdEnum } from '@app/types/smart-editor/template-enums' ;
13
- import { ArrowUpIcon , ExclamationmarkTriangleIcon } from '@navikt/aksel-icons' ;
4
+ import { ExclamationmarkTriangleIcon } from '@navikt/aksel-icons' ;
14
5
import { HStack , Heading } from '@navikt/ds-react' ;
15
- import { skipToken } from '@reduxjs/toolkit/query' ;
16
- import { useCallback , useContext } from 'react' ;
17
6
18
7
interface Props {
19
8
headingId : string ;
@@ -22,24 +11,6 @@ interface Props {
22
11
export const NewDocumentsHeader = ( { headingId } : Props ) => {
23
12
const errorMessage = useValidationError ( 'underArbeid' ) ;
24
13
const [ isExpanded ] = useIsExpanded ( ) ;
25
- const oppgaveId = useOppgaveId ( ) ;
26
- const [ setParent ] = useSetParentMutation ( ) ;
27
- const { draggedDocument, clearDragState } = useContext ( DragAndDropContext ) ;
28
- const isSaksbehandler = useIsSaksbehandler ( ) ;
29
- const hasOppgavestyringRole = useHasRole ( Role . KABAL_OPPGAVESTYRING_ALLE_ENHETER ) ;
30
- const isDropTarget = ( isSaksbehandler || hasOppgavestyringRole ) && isDroppable ( draggedDocument ) ;
31
-
32
- const onDrop = useCallback ( ( ) => {
33
- if ( isDropTarget && oppgaveId !== skipToken ) {
34
- setParent ( {
35
- dokumentId : draggedDocument . id ,
36
- oppgaveId,
37
- parentId : null ,
38
- } ) ;
39
- }
40
-
41
- clearDragState ( ) ;
42
- } , [ clearDragState , draggedDocument , isDropTarget , oppgaveId , setParent ] ) ;
43
14
44
15
return (
45
16
< HStack
@@ -52,27 +23,13 @@ export const NewDocumentsHeader = ({ headingId }: Props) => {
52
23
wrap = { false }
53
24
className = "border-border-divider border-b"
54
25
>
55
- < DropZone
56
- onDrop = { onDrop }
57
- icon = { < ArrowUpIcon aria-hidden /> }
58
- label = "Hoveddokument"
59
- active = { isDropTarget }
60
- className = "grow"
61
- >
62
- < Heading size = "xsmall" level = "2" id = { headingId } >
63
- Dokumenter under arbeid
64
- </ Heading >
65
- { typeof errorMessage === 'string' ? (
66
- < ExclamationmarkTriangleIcon title = { errorMessage } className = "text-text-danger" />
67
- ) : null }
68
- </ DropZone >
26
+ < Heading size = "xsmall" level = "2" id = { headingId } >
27
+ Dokumenter under arbeid
28
+ </ Heading >
29
+ { typeof errorMessage === 'string' ? (
30
+ < ExclamationmarkTriangleIcon title = { errorMessage } className = "text-text-danger" />
31
+ ) : null }
69
32
{ isExpanded ? < DeleteDropArea /> : null }
70
33
</ HStack >
71
34
) ;
72
35
} ;
73
-
74
- const isDroppable = ( draggedDocument : IMainDocument | null ) : draggedDocument is IMainDocument =>
75
- draggedDocument !== null &&
76
- draggedDocument . parentId !== null &&
77
- draggedDocument . type !== DocumentTypeEnum . JOURNALFOERT &&
78
- draggedDocument . templateId !== TemplateIdEnum . ROL_ANSWERS ;
0 commit comments