// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import type { JSXElement } from "@coreai-ds/react-components";
import { useId } from "@coreai-ds/react-components";
import { useToastController } from "@coreai-ds/react-components";
import { Toast } from "@coreai-ds/react-components";
import { ToastTitle } from "@coreai-ds/react-components";
import { Toaster } from "@coreai-ds/react-components";
import { Button } from "@coreai-ds/react-components";
import * as React from 'react';

export const DismissAll = (): JSXElement => {
    const toasterId = useId('toaster');
    const { dispatchToast, dismissAllToasts } = useToastController(toasterId);
    const notify = () => dispatchToast(<Toast>
        <ToastTitle>This is a toast</ToastTitle>
      </Toast>, { intent: 'info' });
    const dismissAll = () => dismissAllToasts();
    return (<>
      <Toaster toasterId={toasterId}/>
      <Button onClick={notify}>Make toast</Button>
      <Button onClick={dismissAll}>Dismiss all toasts</Button>
    </>);
};

export default DismissAll;
