-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(edit): duplicate existing board (#1564)
- Loading branch information
1 parent
f9ee810
commit 2943610
Showing
5 changed files
with
121 additions
and
6 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
42 changes: 42 additions & 0 deletions
42
next-tavla/app/(admin)/edit/[id]/components/ActionsMenu/index.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,42 @@ | ||
'use client' | ||
import { OverflowMenu } from '@entur/menu' | ||
import { TBoard, TOrganizationID } from 'types/settings' | ||
import { DuplicateBoard } from '../DuplicateBoard' | ||
import { Delete } from 'app/(admin)/boards/components/Column/Delete' | ||
|
||
function ActionsMenu({ board, oid }: { board: TBoard; oid?: TOrganizationID }) { | ||
return ( | ||
<> | ||
<OverflowActionsMenu board={board} oid={oid} /> | ||
<ButtonsMenu board={board} oid={oid} /> | ||
</> | ||
) | ||
} | ||
|
||
function OverflowActionsMenu({ | ||
board, | ||
oid, | ||
}: { | ||
board: TBoard | ||
oid?: TOrganizationID | ||
}) { | ||
return ( | ||
<div className="hidden md:flex"> | ||
<OverflowMenu position="left"> | ||
<DuplicateBoard board={board} oid={oid} /> | ||
<Delete board={board} type="action" /> | ||
</OverflowMenu> | ||
</div> | ||
) | ||
} | ||
|
||
function ButtonsMenu({ board, oid }: { board: TBoard; oid?: TOrganizationID }) { | ||
return ( | ||
<div className="flex flex-col md:flex-row md:items-center gap-4 md:hidden"> | ||
<DuplicateBoard board={board} oid={oid} type="button" /> | ||
<Delete board={board} type="button" /> | ||
</div> | ||
) | ||
} | ||
|
||
export { ActionsMenu } |
54 changes: 54 additions & 0 deletions
54
next-tavla/app/(admin)/edit/[id]/components/DuplicateBoard/index.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,54 @@ | ||
'use client' | ||
import { useToast } from '@entur/alert' | ||
import { Button } from '@entur/button' | ||
import { AddIcon } from '@entur/icons' | ||
import { OverflowMenuItem } from '@entur/menu' | ||
import { create } from 'app/(admin)/components/CreateBoard/actions' | ||
import { TBoard, TOrganizationID } from 'types/settings' | ||
|
||
function DuplicateBoard({ | ||
board, | ||
oid, | ||
type, | ||
}: { | ||
board: TBoard | ||
oid?: TOrganizationID | ||
type?: 'button' | 'action' | ||
}) { | ||
const { addToast } = useToast() | ||
const handleSelect = async () => { | ||
delete board.id | ||
await create( | ||
{ | ||
...board, | ||
meta: { | ||
...board.meta, | ||
title: board.meta.title + ' - duplikat', | ||
}, | ||
}, | ||
oid, | ||
) | ||
addToast('Tavle duplisert!') | ||
} | ||
if (type === 'button') | ||
return ( | ||
<Button | ||
variant="secondary" | ||
aria-label="Dupliser tavle" | ||
onClick={handleSelect} | ||
> | ||
Dupliser Tavle | ||
<AddIcon /> | ||
</Button> | ||
) | ||
return ( | ||
<OverflowMenuItem onSelect={handleSelect}> | ||
<div className="flex flex-row"> | ||
<AddIcon inline /> | ||
Dupliser tavle | ||
</div> | ||
</OverflowMenuItem> | ||
) | ||
} | ||
|
||
export { DuplicateBoard } |
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