This commit is contained in:
wrzesinski-hubert
2020-10-28 00:07:23 +01:00
parent c16561cfd1
commit 0ea3ed69d1
2 changed files with 16 additions and 1 deletions

View File

@ -24,6 +24,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
const [basket, setBasket] = useState<Array<Basket>>([]);
const { enqueueSnackbar } = useSnackbar();
const { closeSnackbar } = useSnackbar();
const CAS = useContext(CASContext)!;
const token = CAS?.user?.token;
@ -60,14 +61,28 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
data: JSON.stringify(basketIds),
};
const action = (key: any) => (
<>
<button
onClick={() => {
closeSnackbar(key);
}}
>
X
</button>
</>
);
try {
await axios.request(config);
enqueueSnackbar('Plan został zapisany', {
variant: 'success',
action,
});
} catch (e) {
enqueueSnackbar('Zapisywanie planu nie powiodło się', {
variant: 'error',
action,
});
}
};