Skip to content

Commit a7700a0

Browse files
authored
fix(rediger): save settings on combined tile (#1865)
* fix(rediger): save settings on combined tile * chore(): delete compress survey
1 parent 2aab07a commit a7700a0

File tree

5 files changed

+138
-201
lines changed

5 files changed

+138
-201
lines changed

tavla/app/(admin)/tavler/[id]/rediger/components/CompressSurvey/index.tsx

Lines changed: 0 additions & 179 deletions
This file was deleted.

tavla/app/(admin)/tavler/[id]/rediger/components/TileCard/actions.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,7 @@ export async function saveTile(bid: TBoardID, tile: TTile) {
6565
})
6666
const indexExistingTile = board.tiles.indexOf(existingTile)
6767

68-
if (tile.displayName) {
69-
board.tiles[indexExistingTile] = {
70-
...tile,
71-
displayName: tile.displayName.substring(0, 50),
72-
}
73-
} else {
74-
board.tiles[indexExistingTile] = tile
75-
}
76-
68+
board.tiles[indexExistingTile] = tile
7769
boardRef.update({ tiles: board.tiles, 'meta.dateModified': Date.now() })
7870

7971
revalidatePath(`/tavler/${bid}/rediger`)

tavla/app/(admin)/tavler/[id]/rediger/components/TileCard/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function TileCard({
9393
useState(walkingDistanceInMinutes === tile.offset)
9494

9595
const [offset, setOffset] = useState(tile.offset ?? '')
96+
const [displayName, setDisplayName] = useState(tile.displayName ?? '')
9697

9798
const submit = async (
9899
prevState: TFormFeedback | undefined,
@@ -106,9 +107,11 @@ function TileCard({
106107
data.delete('offset')
107108
const displayName = data.get('displayName') as string
108109
data.delete('displayName')
110+
109111
if (isOnlyWhiteSpace(displayName)) {
110112
return getFormFeedbackForError('board/tiles-name-missing')
111113
}
114+
112115
let lines: string[] = []
113116
for (const line of data.values()) {
114117
lines.push(line as string)
@@ -142,6 +145,7 @@ function TileCard({
142145
reset()
143146
}
144147
const [state, action] = useActionState(submit, undefined)
148+
145149
useEffect(() => {
146150
if (!address) {
147151
setOffsetBasedOnWalkingDistance(false)
@@ -301,9 +305,14 @@ function TileCard({
301305
label="Navn på stoppested"
302306
className="!w-full md:!w-1/2 lg:!w-1/4"
303307
name="displayName"
304-
defaultValue={tile.displayName}
305-
disabled={isCombined}
308+
value={displayName}
309+
readOnly={isCombined}
306310
maxLength={50}
311+
clearable={!isCombined}
312+
onClear={() => {
313+
setDisplayName('')
314+
}}
315+
onChange={(e) => setDisplayName(e.target.value)}
307316
{...getFormFeedbackForField('name', state)}
308317
/>
309318
</div>

tavla/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@entur/chip": "0.7.23",
2828
"@entur/dropdown": "6.0.13",
2929
"@entur/expand": "^3.6.0",
30-
"@entur/form": "8.1.5",
30+
"@entur/form": "8.2.4",
3131
"@entur/icons": "7.7.0",
3232
"@entur/layout": "2.3.18",
3333
"@entur/loader": "0.5.12",

0 commit comments

Comments
 (0)