Skip to content

Commit

Permalink
fix(boards): disabled switch no walkingdistance (#1558)
Browse files Browse the repository at this point in the history
  • Loading branch information
purusott authored Jun 21, 2024
1 parent ebd2730 commit 9e67b98
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 13 additions & 4 deletions next-tavla/app/(admin)/edit/[id]/components/TileCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ import { deleteTile, getOrganizationForBoard, saveTile } from './actions'
import { useLines } from './useLines'
import { sortLineByPublicCode } from './utils'
import { TransportModeAndLines } from './TransportModeAndLines'
import { TLocation } from 'types/meta'

function TileCard({ bid, tile }: { bid: TBoardID; tile: TTile }) {
function TileCard({
bid,
tile,
address,
}: {
bid: TBoardID
tile: TTile
address?: TLocation
}) {
const posthog = usePostHog()
const [isOpen, setIsOpen] = useState(false)
const [changed, setChanged] = useState(false)
Expand All @@ -46,7 +55,7 @@ function TileCard({ bid, tile }: { bid: TBoardID; tile: TTile }) {
if (!lines)
return (
<div className="flex justify-between items-center bg-secondary p-4 rounded">
Laster..
Laster...
</div>
)

Expand Down Expand Up @@ -164,18 +173,18 @@ function TileCard({ bid, tile }: { bid: TBoardID; tile: TTile }) {
stoppestedet
</SubParagraph>
<div className="flex flex-col">
{tile.walkingDistance?.visible ?? (
{!address?.name && (
<Label className="!text-error">
Du må legge til en lokasjon for å kunne skru
på gåavstand
</Label>
)}
<Switch
name="showDistance"
disabled={address ? false : true}
defaultChecked={
tile.walkingDistance?.visible ?? false
}
disabled={tile.walkingDistance ? false : true}
>
Vis gåavstand
</Switch>
Expand Down
7 changes: 6 additions & 1 deletion next-tavla/app/(admin)/edit/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ export default async function EditPage({ params }: TProps) {
}}
/>
{board.tiles.map((tile) => (
<TileCard key={tile.uuid} bid={params.id} tile={tile} />
<TileCard
key={tile.uuid}
bid={params.id}
tile={tile}
address={board.meta.location}
/>
))}
</div>

Expand Down

0 comments on commit 9e67b98

Please sign in to comment.