Skip to content

Instantly share code, notes, and snippets.

@sumitkharche
Last active May 9, 2020 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumitkharche/3c2b5eb9dd5325e5e7f333fe1ed7a0eb to your computer and use it in GitHub Desktop.
Save sumitkharche/3c2b5eb9dd5325e5e7f333fe1ed7a0eb to your computer and use it in GitHub Desktop.
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