main

mattermost/focalboard

Last updated at: 28/12/2023 01:42

checkbox.tsx

TLDR

This file is a React component that renders a checkbox property for a card in a board. The component uses the Switch widget to display the checkbox and handles the logic for updating the checkbox value when it is toggled.

Methods

N/A

Classes

N/A

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React from 'react'

import mutator from '../../mutator'
import Switch from '../../widgets/switch'

import {PropertyProps} from '../types'

const Checkbox = (props: PropertyProps): JSX.Element => {
    const {card, board, propertyTemplate, propertyValue} = props
    return (
        <Switch
            isOn={Boolean(propertyValue)}
            onChanged={(newBool: boolean) => {
                const newValue = newBool ? 'true' : ''
                mutator.changePropertyValue(board.id, card, propertyTemplate?.id || '', newValue)
            }}
            readOnly={props.readOnly}
        />
    )
}
export default Checkbox