Skip to content

Commit

Permalink
fix(#21): close create list modal after entry
Browse files Browse the repository at this point in the history
  • Loading branch information
shuveksha-tuladhar committed Oct 9, 2024
1 parent 60df053 commit 060e6c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/views/CreateList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export function CreateList({
isCreateListModalOpen,
setIsCreateListModalOpen,
user,
setListPath,
}) {
const userId = user?.uid;
const userEmail = user?.email;

const [listPath, setListPath] = useState('');
const [listName, setListName] = useState('');

const handleChange = (event) => {
Expand All @@ -27,6 +27,7 @@ export function CreateList({
const newListPath = await createList(userId, userEmail, listName);
notify('List is sucessfully created', 'success');
setListPath(newListPath);
setIsCreateListModalOpen(false);
} catch {
notify('There was an error adding your list', 'error');
}
Expand Down Expand Up @@ -58,7 +59,7 @@ export function CreateList({
<IconButton
aria-label="Add a list"
as="button"
className="inline-flex justify-center rounded-md bg-[#184E77] px-4 py-[.75rem] text-lg font-medium text-white shadow-sm hover:bg-[#1E6091] transition duration-200 ease-in-out mr-10"
className="inline-flex justify-center rounded-md bg-btnPrimary px-4 py-[.75rem] text-lg font-medium text-white shadow-sm hover:bg-btnPrimary transition duration-200 ease-in-out mr-10"
label="Add"
IconComponent={FaPlusSquare}
type="submit"
Expand All @@ -67,7 +68,7 @@ export function CreateList({
aria-label="Cancel adding"
as="button"
onClick={() => setIsCreateListModalOpen(false)}
className="inline-flex justify-center rounded-md bg-[#184E77] px-4 py-[.75rem] text-lg font-medium text-white shadow-sm ring-1 ring-gray-300 hover:bg-[#1E6091] transition duration-200 ease-in-out" // Increased button padding and font size
className="inline-flex justify-center rounded-md bg-btnPrimary px-4 py-[.75rem] text-lg font-medium text-white shadow-sm ring-1 ring-gray-300 hover:bg-btnPrimary transition duration-200 ease-in-out" // Increased button padding and font size
label="Cancel"
IconComponent={FaTimes}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/views/Disclosure.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function Disclosure({
listpath,
setListPath,
}) {
const [isOpen, setIsOpen] = useState(false);
const [isOpen, setIsOpen] = useState(listpath === currentListPath);

useEffect(() => {
if (currentListPath !== listpath) {
Expand Down
1 change: 1 addition & 0 deletions src/views/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function Home({ data, lists, listPath, setListPath, user }) {
isCreateListModalOpen={isCreateListModalOpen}
setIsCreateListModalOpen={setIsCreateListModalOpen}
user={user}
setListPath={setListPath}
/>
)}
<div className="flex justify-center items-center">
Expand Down

0 comments on commit 060e6c0

Please sign in to comment.