Skip to content
Snippets Groups Projects
Commit 1d3c4c21 authored by Richard Fernando Heise Ferreira's avatar Richard Fernando Heise Ferreira
Browse files

Merge branch 'issue-336/FIX-date-invalid-on-comments+fix-bug-auto-follow' into 'develop'

Issue #336: FIX date invalid on comments and fix bug auto follow on collection page

See merge request !314
parents 254bc857 79ca5e46
No related branches found
No related tags found
1 merge request!314Issue #336: FIX date invalid on comments and fix bug auto follow on collection page
Pipeline #42514 passed
...@@ -8,11 +8,30 @@ import { isLoggedIn } from "@/app/handlers/loginHandler"; ...@@ -8,11 +8,30 @@ import { isLoggedIn } from "@/app/handlers/loginHandler";
export default function PublisherInfoCollection({ publisher, disabledButton = false }) { export default function PublisherInfoCollection({ publisher, disabledButton = false }) {
const [followed, setFollowed] = useState(false); const [followed, setFollowed] = useState(false);
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [myCollection, setMyCollection] = useState(false)
const loginBarrier = useLoginBarrier(); const loginBarrier = useLoginBarrier();
const token = getStoredValue("access_token") const token = getStoredValue("access_token")
const client = getStoredValue("client") const client = getStoredValue("client")
const uid = getStoredValue("uid") const uid = getStoredValue("uid")
const [userData, setUserData] = useState(null)
// PEgar as informações do usuario e fazer a comparação com o que vem do publisher
//verificar se os ID são iguais
//criar outra variavel para verificar isso para usar no if abaixo
useEffect(() => {
if (!isLoggedIn()) return;
const data = JSON.parse(getStoredValue("user_data"));
setUserData(data);
if (data?.id === publisher?.id) {
setMyCollection(true);
} else {
setMyCollection(false);
}
}, [token, publisher]);
useEffect(() => { useEffect(() => {
setFollowed(publisher?.followed ?? false); setFollowed(publisher?.followed ?? false);
...@@ -40,6 +59,7 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa ...@@ -40,6 +59,7 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa
setFollowed((old) => !old); setFollowed((old) => !old);
}; };
function getRandomBg(id) { function getRandomBg(id) {
const colors = [ const colors = [
"bg-turquoise-HC-white", "bg-turquoise-HC-white",
...@@ -61,7 +81,7 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa ...@@ -61,7 +81,7 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa
<> <>
<div className="bg-white-HC-dark outline outline-1 outline-ice-HC-white shadow-none flex flex-col flex-shrink rounded-xl p-0 my-1 normal-case text-sm font-bold"> <div className="bg-white-HC-dark outline outline-1 outline-ice-HC-white shadow-none flex flex-col flex-shrink rounded-xl p-0 my-1 normal-case text-sm font-bold">
<Button href={`/perfil/${publisher.id}`} > <Button href={`/perfil/${publisher.id}`} >
<div className="flex flex-row truncate"> <div className="flex flex-row w-full truncate justify-start">
{publisher?.avatar ? ( {publisher?.avatar ? (
<Avatar <Avatar
fill="true" fill="true"
...@@ -83,14 +103,15 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa ...@@ -83,14 +103,15 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa
</div> </div>
</div> </div>
</Button> </Button>
<div className="flex justify-center flex-grow flex-shrink-0 p-3 truncate max-sm:justify-start"> <div className={`flex flex-grow flex-shrink-0 p-3 truncate max-sm:justify-start ${myCollection ? "justify-start" : "justify-center"}`}>
<Button <Button
disabled={disabledButton} disabled={disabledButton}
href={`/perfil/${publisher.id}`} href={`/perfil/${publisher.id}`}
className="outline outline-1 flex-grow outline-ice-HC-white hover:bg-lightGray-HC-white bg-white-HC-dark h-12 text-darkGray-HC-white border border-solid border-main shadow-none rounded-xl p-3 m-1 mr-3 px-8 normal-case font-bold" className={`outline outline-1 outline-ice-HC-white hover:bg-lightGray-HC-white bg-white-HC-dark h-12 text-darkGray-HC-white border border-solid border-main shadow-none rounded-xl p-3 m-1 mr-3 px-8 normal-case font-bold ${myCollection ? " flex justify-start" : "flex-grow"}`}
> >
Ver Perfil Ver Perfil
</Button> </Button>
{!myCollection ? (
<Button <Button
disabled={disabledButton} disabled={disabledButton}
onClick={followHandler} onClick={followHandler}
...@@ -98,6 +119,8 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa ...@@ -98,6 +119,8 @@ export default function PublisherInfoCollection({ publisher, disabledButton = fa
> >
{followed ? "Seguindo" : "Seguir"} {followed ? "Seguindo" : "Seguir"}
</Button> </Button>
) : null}
</div> </div>
</div> </div>
</> </>
......
...@@ -32,8 +32,6 @@ export function EditResourceModal({ open, onClose, resource, setEditOpen }) { ...@@ -32,8 +32,6 @@ export function EditResourceModal({ open, onClose, resource, setEditOpen }) {
"name": title, "name": title,
"description": description "description": description
} }
console.log("aa")
try { try {
await mecredApi.put(`/learning_objects/${resource?.learning_object.id}.json`, payload, { await mecredApi.put(`/learning_objects/${resource?.learning_object.id}.json`, payload, {
headers: { headers: {
......
...@@ -31,7 +31,6 @@ export default function ShareModal({ open, onClose, learningObject, title, type, ...@@ -31,7 +31,6 @@ export default function ShareModal({ open, onClose, learningObject, title, type,
.catch((error) => console.error("Erro ao compartilhar:", error)); .catch((error) => console.error("Erro ao compartilhar:", error));
} }
//console.log ("teste", learningObject)
return ( return (
<Modal <Modal
......
...@@ -189,7 +189,6 @@ export default function ActionButtons({ learningObject, setNeedLoginOpen, state ...@@ -189,7 +189,6 @@ export default function ActionButtons({ learningObject, setNeedLoginOpen, state
</Button> </Button>
); );
console.log(learningObject)
return ( return (
<> <>
<DeleteModal open={deleteOpen} onClose={() => setDeleteOpen(false)} idLogin={userData["id"]} resourceId={learningObject.id} /> <DeleteModal open={deleteOpen} onClose={() => setDeleteOpen(false)} idLogin={userData["id"]} resourceId={learningObject.id} />
......
...@@ -45,8 +45,10 @@ export default function PrintComments({ comment, userData, learningObjectId, com ...@@ -45,8 +45,10 @@ export default function PrintComments({ comment, userData, learningObjectId, com
else if (((mes = Math.floor(dia / 31)) > 0)) else if (((mes = Math.floor(dia / 31)) > 0))
return <span className="text-sm font-light"> {mes} {mes === 1 ? "mês" : "meses"}</span> return <span className="text-sm font-light"> {mes} {mes === 1 ? "mês" : "meses"}</span>
if (dia === 0) if (dia <= 0) {
dia = 0
return <span className="text-sm font-light"> hoje</span> return <span className="text-sm font-light"> hoje</span>
}
return <span className="text-sm font-light"> {dia} {dia === 1 ? "dia" : "dias"}</span> return <span className="text-sm font-light"> {dia} {dia === 1 ? "dia" : "dias"}</span>
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment