1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/hooks/useToast.tsx
Fredrik Strand Oseberg c0da8ed6bc Feat/new toggle overview (#497)
* feat: toggle overview accordions

* feat: accordion metrics

* feat: result

* add permission button

* fix: remove feature environment container from strategies tab

* chore: delete unused code

* fix: remove console log

* fix: remove unused code

* fix: cleanup

* fix: refactor

* fix: add empty states

* fix: loading

* feat: mobile accordions

* fix: button

* fix: strategies

* fix: cleanup

* fix: remove unused params

* fix: strategy button container

* fix: alter gradual rollout id

* fix: update userid strategy item

* fix: string truncator

* fix: strategy link

* fix: strategies tab

* fix: remove unused imports

* fix: visual improvements

* fix: add border
2021-11-12 11:47:19 +01:00

35 lines
819 B
TypeScript

import { Dispatch, SetStateAction, useState } from 'react';
import Toast from '../component/common/Toast/Toast';
export interface IToast {
show: boolean;
type: 'success' | 'info' | 'warning' | 'error';
text: string;
}
export type TSetToastData = Dispatch<SetStateAction<IToast>>;
const useToast = () => {
const [toastData, setToastData] = useState<IToast>({
show: false,
type: 'success',
text: '',
});
const hideToast = () => {
setToastData((prev: IToast) => ({ ...prev, show: false }));
};
const toast = (
<Toast
show={toastData.show}
onClose={hideToast}
text={toastData.text}
type={toastData.type}
/>
);
return { toast, setToastData, hideToast };
};
export default useToast;