-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/add settings modal to folder card (#245)
* Fix: updated styling for folder * Fix: updated styling for media card * Fix: handle modal closing on blur for OverviewCard * Feat: add folderModal to allow users to change name of folders * Fix: remove resource room name change from settings * Feat: add dropdown to FolderCard * Fix: close dropdown on OverviewCard when delete button is used * Fix: adjust FolderModal proptypes * Fix: right align modal buttons
- Loading branch information
1 parent
77add6c
commit 49a6eee
Showing
7 changed files
with
197 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React, { useState } from 'react'; | ||
import axios from 'axios'; | ||
import PropTypes from 'prop-types'; | ||
import elementStyles from '../styles/isomer-cms/Elements.module.scss'; | ||
import SaveDeleteButtons from './SaveDeleteButtons'; | ||
import FormField from './FormField'; | ||
|
||
// axios settings | ||
axios.defaults.withCredentials = true | ||
|
||
const FolderModal = ({ displayTitle, displayText, onClose, category, siteName, isCollection }) => { | ||
const [newCategoryName, setNewCategoryName] = useState(category) | ||
|
||
const folderNameChangeHandler = (event) => { | ||
const { value } = event.target | ||
setNewCategoryName(value) | ||
} | ||
|
||
const saveHandler = async () => { | ||
try { | ||
await axios.post(`${process.env.REACT_APP_BACKEND_URL}/sites/${siteName}/${isCollection ? 'collections' : 'resources'}/${category}/rename/${newCategoryName}`) | ||
// Refresh page | ||
window.location.reload(); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
} | ||
|
||
return ( | ||
<div className={elementStyles.overlay}> | ||
<div className={elementStyles['modal-settings']}> | ||
<div className={elementStyles.modalHeader}> | ||
<h1> | ||
{displayTitle} | ||
</h1> | ||
<button type="button" onClick={onClose}> | ||
<i className="bx bx-x" /> | ||
</button> | ||
</div> | ||
<form className={elementStyles.modalContent}> | ||
<FormField | ||
title={displayText} | ||
id="newCategoryName" | ||
value={newCategoryName} | ||
onFieldChange={folderNameChangeHandler} | ||
/> | ||
<SaveDeleteButtons | ||
isDisabled={false} | ||
hasDeleteButton={false} | ||
saveCallback={saveHandler} | ||
/> | ||
</form> | ||
</div> | ||
</div> | ||
) | ||
}; | ||
|
||
FolderModal.propTypes = { | ||
displayTitle: PropTypes.string.isRequired, | ||
displayText: PropTypes.string.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
category: PropTypes.string.isRequired, | ||
siteName: PropTypes.string.isRequired, | ||
isCollection: PropTypes.bool, | ||
}; | ||
|
||
export default FolderModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ | |
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-start; | ||
margin-left: auto; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters