Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(boards): disabled switch no walkingdistance #1558

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -78,7 +78,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