Skip to content

Commit

Permalink
show loader on create of a project (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Jul 8, 2024
1 parent 3462ba2 commit c358c44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/new/widget/page/projects/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,15 @@ const [projectIdForSocialDB, setProjectId] = useState(null); // for edit changes
const [contributorSearchTerm, setContributorSearch] = useState("");
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showDeleteSuccessModal, setShowDeleteSuccessModal] = useState(false);
const [onCreateLoader, setCreateLoader] = useState(false);

function removeWhiteSpace(str) {
return str.replace(/\s/g, "-").toLowerCase();
}

function convertArrayToObject(array) {
const obj = {};
array.forEach((value, index) => {
(array ?? []).forEach((value, index) => {
obj[value] = "";
});
return obj;
Expand Down Expand Up @@ -568,6 +569,7 @@ const DeleteConfirmationModal = () => {
};

function onCreateProject() {
setCreateLoader(true);
const projectID = isEditScreen ? projectIdForSocialDB : normalize(title, "-");
const project = {
title,
Expand Down Expand Up @@ -651,8 +653,10 @@ function onCreateProject() {
} else {
Social.set(data, {
onCommit: () => {
setCreateLoader(false);
setShowSuccessModal(true);
},
onCancel: () => setCreateLoader(false),
});
}
}
Expand Down Expand Up @@ -759,6 +763,7 @@ const DeleteProjectBtn = () => {
<Button
variant="outline"
className="destructive"
loading={showDeleteModal}
onClick={() => setShowDeleteModal(true)}
>
Delete Project
Expand Down Expand Up @@ -943,6 +948,7 @@ const SecondScreen = () => {
variant="primary"
onClick={onCreateProject}
disabled={invalidContributorFound}
loading={onCreateLoader}
>
{isEditScreen ? "Save Changes" : "Create"}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/old/widget/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function Button({
return (
<StyledButton
id={id}
disabled={disabled}
disabled={disabled || loading}
key={`Button-${type ?? "Normal"}-${variant ?? "Default"}-${id}`}
className={className}
variant={variant}
Expand Down

0 comments on commit c358c44

Please sign in to comment.