Last active
May 9, 2020 14:49
-
-
Save sumitkharche/3c2b5eb9dd5325e5e7f333fe1ed7a0eb to your computer and use it in GitHub Desktop.
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
import React, { useState } from 'react'; | |
import { Stack, Label, IconButton, Dialog, DialogFooter, DefaultButton, PrimaryButton, DialogType } from '@fluentui/react'; | |
function TodoItem(props: any) { | |
const [openDeleteModal, setOpenModal] = useState(true); | |
const deleteTodo = (id: number) => { | |
props.deleteTodo(id); | |
setOpenModal(true); | |
} | |
return ( | |
<Stack> | |
<Stack horizontal verticalAlign="center" horizontalAlign="space-between"> | |
<Label>{props.todo.name}</Label> | |
<IconButton iconProps={{ iconName: 'trash' }} className="clearButton" onClick={() => { setOpenModal(!openDeleteModal) }} /> | |
</Stack> | |
<Dialog | |
hidden={openDeleteModal} | |
dialogContentProps={{ | |
type: DialogType.normal, | |
title: "Delete", | |
subText: | |
"Are you sure you want to delete this item? This cannot be undone." | |
}} | |
modalProps={{ | |
isBlocking: false | |
}} | |
> | |
<DialogFooter> | |
<PrimaryButton text="Yes" onClick={() => { deleteTodo(props.todo.id) }} /> | |
<DefaultButton text="No" onClick={() => { setOpenModal(true) }} /> | |
</DialogFooter> | |
</Dialog> | |
</Stack> | |
); | |
} | |
export default TodoItem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment