Skip to content

Commit

Permalink
Chaos 169 update orgs list when creating org (#440)
Browse files Browse the repository at this point in the history
* Implemented error notifications for organisation creation

* Additional error added

* Changed error messages to use modern pushToast

---------

Co-authored-by: Dane Urban <[email protected]>
  • Loading branch information
Danelegend and Dane Urban authored Jul 19, 2023
1 parent 5edef75 commit 32e2d1a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions frontend/src/components/AdminSideBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useState } from "react";
import { useContext, useState } from "react";

import { pushToast } from "utils";

import { createOrganisation, putOrgLogo } from "../../api";
import CreateOrganisationForm from "../CreateOrganisationForm";
Expand Down Expand Up @@ -78,9 +80,30 @@ const AdminSidebar = ({
setUploadedImage({ image: null, url: null });
setInputText("");
setIsFormOpen(false);
console.log("New organisation created!");

pushToast(
"Organisation Creation Successful",
"Organisation successfully created",
"success"
);
} else if (!inputText) {
pushToast(
"Organisation Creation Error",
"Organisation name is required!",
"error"
);
} else if (!uploadedImage.image) {
pushToast(
"Organisation Creation Error",
"Organisation logo image is required!",
"error"
);
} else {
console.error("Both image and text are required!");
pushToast(
"Organisation Creation Error",
"Organisation unknown error occurred!",
"error"
);
}
};

Expand Down

0 comments on commit 32e2d1a

Please sign in to comment.