From 260a6434b71b67dea57db99af88988f878385f11 Mon Sep 17 00:00:00 2001 From: AlbertLnz Date: Thu, 28 Sep 2023 09:36:59 +0200 Subject: [PATCH 01/11] Change collapse with daisyUI component --- .../faqs/faqsAdminView/FaqsModified.tsx | 80 +++++-------------- 1 file changed, 21 insertions(+), 59 deletions(-) diff --git a/src/components/faqs/faqsAdminView/FaqsModified.tsx b/src/components/faqs/faqsAdminView/FaqsModified.tsx index d0827c4..76c7ec3 100644 --- a/src/components/faqs/faqsAdminView/FaqsModified.tsx +++ b/src/components/faqs/faqsAdminView/FaqsModified.tsx @@ -10,8 +10,6 @@ export default function FaqsModified() { //constantes para el set // const dispatch = useDispatch(); - const [booleanFaqs, setBooleanFaqs] = useState(false); - const [faqsContent, setFaqsContent] = useState<{ title: string; description: string; @@ -19,69 +17,33 @@ export default function FaqsModified() { title: "", description: "", }); + const [isOpen, setIsOpen] = useState(false); + + const handleClosed = () => { + setIsOpen(false) + setFaqsContent({ title: "", description: "" }) + } + const handleCreated = () => { + postApiFaqs(faqsContent, acces_token, dispatch) + setIsOpen(false) + setFaqsContent({ title: "", description: "" }) + } return ( <> -
- setBooleanFaqs(!booleanFaqs)} - type="checkbox" - className="peer" - /> -
- Crear nueva pregunta +
+ setIsOpen(true)} /> +
+ {isOpen ? setFaqsContent({ ...faqsContent, title: e.target.value })} value={faqsContent.title}/> :

Crear nueva pregunta

}
-
- - {booleanFaqs == true && ( -
-
- - setFaqsContent({ ...faqsContent, title: e.target.value }) - } - value={faqsContent.title} - type="text" - placeholder="Crea tu pregunta" - className="placeholder-white bg-transparent text-white p-4 w-full focus:border-0 focus:outline-none" - /> -
-
- +
+ +
- )} +
); } From ad4e6fc7ce856e1e5ae3ab1e2e86a6bdfa207dc0 Mon Sep 17 00:00:00 2001 From: AlbertLnz Date: Thu, 28 Sep 2023 10:14:36 +0200 Subject: [PATCH 02/11] AdminButtons of faqs admin view created (non-responsive) --- src/assets/img/plus.svg | 3 + src/assets/img/user.svg | 4 + src/components/BackOfficeComponent.tsx | 10 +- src/components/faqs/FAQsComponent.tsx | 92 +++++++++---------- .../faqs/faqsAdminView/AdminButtons.tsx | 17 ++++ 5 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 src/assets/img/plus.svg create mode 100644 src/assets/img/user.svg create mode 100644 src/components/faqs/faqsAdminView/AdminButtons.tsx diff --git a/src/assets/img/plus.svg b/src/assets/img/plus.svg new file mode 100644 index 0000000..d217c5f --- /dev/null +++ b/src/assets/img/plus.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/img/user.svg b/src/assets/img/user.svg new file mode 100644 index 0000000..d5ee283 --- /dev/null +++ b/src/assets/img/user.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/BackOfficeComponent.tsx b/src/components/BackOfficeComponent.tsx index fb42edc..76d87a0 100644 --- a/src/components/BackOfficeComponent.tsx +++ b/src/components/BackOfficeComponent.tsx @@ -4,6 +4,7 @@ import { useEffect, useState } from "react"; import FAQs from "./faqs/FAQsComponent"; import ProjectsComponent from "./apps/ProjectsComponent"; import menu from "../assets/img/menu.png"; +import { AdminButtons } from "./faqs/faqsAdminView/AdminButtons"; function ViewBackOffice({ setIsLogged, @@ -87,7 +88,7 @@ return ( -
+
{/* Mobile */}
@@ -115,14 +116,13 @@ return (
- - {/*
{ setIsDropdownOpen(false)}} className="opacity-25 fixed inset-0 z-40 bg-black">
*/}
)} {!isDropdownOpen && ( <> -
- +
+ +
diff --git a/src/components/faqs/FAQsComponent.tsx b/src/components/faqs/FAQsComponent.tsx index 87f05f4..e4cef7c 100644 --- a/src/components/faqs/FAQsComponent.tsx +++ b/src/components/faqs/FAQsComponent.tsx @@ -118,56 +118,56 @@ const FAQs = () => { } return ( - -
-
-

FAQs

-
- - { window.location.pathname =='/backoffice'&&( ) } - - {faqsClone.map((faq:Faq, index:number) => ( -
- - -
- - {window.location.pathname == '/backoffice' && isContentEditing && index.toString() === positionIndex ? ( setInputNewTitleValue(e.target.value)}/>) : (

{faqsClone[index].title}

)} - - {window.location.pathname == '/backoffice' && titleButtons && ( -
- - {setDeleteModal(true); setSelectedFaqId(faq.id)}} alt="locker" /> -
- )} -
- -
-

- {window.location.pathname == '/backoffice' && isContentEditing && index.toString() === positionIndex ? (