-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace notes sidebar with sheet for better UX (#3109)
Co-authored-by: Alon Peretz <[email protected]>
- Loading branch information
Showing
14 changed files
with
257 additions
and
245 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { FunctionComponent, ComponentProps } from 'react'; | ||
|
||
import { Sheet } from '@/common/components/atoms/Sheet/Sheet'; | ||
import { SheetContent } from '@/common/components/atoms/Sheet/Sheet.Content'; | ||
import { SheetTrigger } from '@/common/components/atoms/Sheet/Sheet.Trigger'; | ||
import { Notes } from './Notes'; | ||
|
||
export type NotesSheetProps = ComponentProps<typeof Sheet> & | ||
ComponentProps<typeof Notes> & { children: React.ReactNode }; | ||
|
||
export const NotesSheet: FunctionComponent<NotesSheetProps> = ({ | ||
open, | ||
onOpenChange, | ||
defaultOpen, | ||
modal = false, | ||
children, | ||
...notesProps | ||
}) => { | ||
return ( | ||
<Sheet open={open} onOpenChange={onOpenChange} modal={modal} defaultOpen={defaultOpen}> | ||
<SheetTrigger asChild>{children}</SheetTrigger> | ||
<SheetContent onPointerDownOutside={e => e.preventDefault()} className="p-0"> | ||
<Notes {...notesProps} /> | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
}; |
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,62 +1,41 @@ | ||
import { Case } from './components/Case/Case'; | ||
import { Notes } from '@/domains/notes/Notes'; | ||
import { TWorkflowById } from '@/domains/workflows/fetchers'; | ||
import { BlocksVariant } from '@/lib/blocks/variants/BlocksVariant/BlocksVariant'; | ||
import { useEntityLogic } from '@/pages/Entity/hooks/useEntityLogic/useEntityLogic'; | ||
import { SidebarInset, SidebarProvider } from '@/common/components/organisms/Sidebar/Sidebar'; | ||
import { Case } from './components/Case/Case'; | ||
|
||
export const Entity = () => { | ||
const { workflow, notes, selectedEntity, isNotesOpen } = useEntityLogic(); | ||
const { workflow, selectedEntity } = useEntityLogic(); | ||
|
||
if (!workflow || !selectedEntity) { | ||
return null; | ||
} | ||
|
||
// Selected entity | ||
return ( | ||
<SidebarProvider | ||
open={isNotesOpen} | ||
style={{ | ||
'--sidebar-width': '25rem', | ||
'--sidebar-width-mobile': '20rem', | ||
}} | ||
> | ||
<SidebarInset> | ||
<Case key={workflow.id}> | ||
{/* Reject and approve header */} | ||
<Case.Actions | ||
numberOfNotes={notes?.length ?? 0} | ||
id={workflow.id} | ||
fullName={selectedEntity.name} | ||
showResolutionButtons={ | ||
workflow.workflowDefinition?.config?.workflowLevelResolution ?? | ||
workflow.context?.entity?.type === 'business' | ||
} | ||
workflow={workflow as TWorkflowById} | ||
/> | ||
<Case.Content key={selectedEntity?.id}> | ||
{workflow.workflowDefinition && ( | ||
<BlocksVariant | ||
workflowDefinition={{ | ||
version: workflow.workflowDefinition?.version, | ||
variant: workflow.workflowDefinition?.variant, | ||
config: workflow.workflowDefinition?.config, | ||
name: workflow.workflowDefinition?.name, | ||
}} | ||
/> | ||
)} | ||
</Case.Content> | ||
</Case> | ||
</SidebarInset> | ||
<Notes | ||
notes={notes ?? []} | ||
noteData={{ | ||
entityId: workflow.entity.id, | ||
entityType: `Business`, | ||
noteableId: workflow.id, | ||
noteableType: `Workflow`, | ||
}} | ||
<Case key={workflow.id}> | ||
{/* Reject and approve header */} | ||
<Case.Actions | ||
id={workflow.id} | ||
entityId={selectedEntity.id} | ||
fullName={selectedEntity.name} | ||
showResolutionButtons={ | ||
workflow.workflowDefinition?.config?.workflowLevelResolution ?? | ||
workflow.context?.entity?.type === 'business' | ||
} | ||
workflow={workflow as TWorkflowById} | ||
/> | ||
</SidebarProvider> | ||
<Case.Content key={selectedEntity?.id}> | ||
{workflow.workflowDefinition && ( | ||
<BlocksVariant | ||
workflowDefinition={{ | ||
version: workflow.workflowDefinition?.version, | ||
variant: workflow.workflowDefinition?.variant, | ||
config: workflow.workflowDefinition?.config, | ||
name: workflow.workflowDefinition?.name, | ||
}} | ||
/> | ||
)} | ||
</Case.Content> | ||
</Case> | ||
); | ||
}; |
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.