-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(edit): toggle optional columns (#1127)
* feat(edit): reducer for optional columns * feat(edit): toggle for optional column platform in edit * feat(edit): created toggelcompoent to add additional information for a certain tile * chore(toggelcolumns): removed unused imports * feat(toggelcolumn): not fixed controlled compoenent * fix(togglecolumn): fixed uncontrolled error component * chore(edit): renamed togglecolumns component * chore(reducer): changed name of togglecolumn to setcolumn in reducer
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Heading3 } from '@entur/typography' | ||
import { useSettingsDispatch } from 'Admin/utils/contexts' | ||
import { DefaultColumns, TColumn } from 'types/column' | ||
import { TTile } from 'types/tile' | ||
import { Switch } from '@entur/form' | ||
|
||
function ToggleColumns({ tile }: { tile: TTile }) { | ||
const dispatch = useSettingsDispatch() | ||
|
||
const optionalColumns: TColumn[] = ['platform', 'via'] | ||
|
||
function handleSwitch(column: TColumn, value: boolean) { | ||
dispatch({ | ||
type: 'setColumn', | ||
column: column, | ||
value: value, | ||
tileId: tile.uuid, | ||
}) | ||
} | ||
const columns = { ...DefaultColumns, ...tile.columns } | ||
return ( | ||
<div> | ||
<Heading3>Legg til informasjon</Heading3> | ||
|
||
{optionalColumns.map((col) => { | ||
return ( | ||
<Switch | ||
key={col} | ||
checked={columns[col]} | ||
onChange={() => handleSwitch(col, !columns[col])} | ||
> | ||
{col} | ||
</Switch> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
export { ToggleColumns } |
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