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

2
package-lock.json generated
View File

@ -2062,7 +2062,7 @@
"dependencies": {
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"resolved": "https://npm.mlabs.pl:443/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}

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,
});
}
};