Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend-MECRED
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MECRED
Frontend-MECRED
Commits
c89a54b3
Commit
c89a54b3
authored
1 month ago
by
Guilherme Eduardo
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#294
: UPDATE remove duplicate user resources
parent
c7f6cb03
No related branches found
No related tags found
No related merge requests found
Pipeline
#41984
passed
1 month ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/perfil/[id]/components/ProfileResources.js
+16
-26
16 additions, 26 deletions
src/app/perfil/[id]/components/ProfileResources.js
with
16 additions
and
26 deletions
src/app/perfil/[id]/components/ProfileResources.js
+
16
−
26
View file @
c89a54b3
...
...
@@ -89,20 +89,21 @@ export default function ProfileResources({ id, idLogin }) {
},
[
resourcesCount
,
homologaCount
])
useEffect
(()
=>
{
// Remove os itens duplicados - Set é uma estrutura de dados
// que não aceita repetição
if
(
resources
.
length
>
0
||
homologaResources
.
length
>
0
)
{
const
unificado
=
[...
resources
,
...
homologaResources
];
const
remove_duplicates
=
[...
new
Set
(
unificado
)]
const
unified
=
[...
resources
,
...
homologaResources
];
// Remove recursos duplicados com base no id (Retorna a primeira ocorrência)
const
remove_duplicates
=
unified
.
filter
((
item
,
index
,
array
)
=>
{
return
array
.
findIndex
(
obj
=>
obj
.
id
===
item
.
id
)
===
index
;
});
// Atualiza o estado com os únicos
setUniqueResources
(
remove_duplicates
);
}
},
[
resources
,
homologaResources
]);
console
.
log
(
"
Recursos:
"
,
resources
)
console
.
log
(
"
Homologados:
"
,
homologaResources
)
console
.
log
(
"
Unificado:
"
,
uniqueResources
)
return
(
<>
{
got
?
(
...
...
@@ -130,27 +131,16 @@ export default function ProfileResources({ id, idLogin }) {
)
:
(
<
div
className
=
"
p-3 my-5 mb-24 mx-5 rounded-md min-w-[200px] min-h-[180px] bg-white-HC-dark
"
>
<
div
className
=
"
flex flex-wrap justify-center
"
>
{
resources
.
map
((
resource
,
index
)
=>
(
<
Cards
id
=
{
resource
.
id
}
key
=
{
index
}
title
=
{
resource
.
name
}
author
=
{
resource
.
publisher
.
name
}
avatar
=
{
resource
.
publisher
.
avatar
}
image
=
{
resource
.
thumbnail
}
updated_at
=
{
resource
.
updated_at
}
/
>
))}
{
homologaResources
.
map
((
resource
,
index
)
=>
(
{
uniqueResources
.
map
((
resource
,
index
)
=>
(
<
Cards
id
=
{
resource
.
id
}
key
=
{
index
}
title
=
{
resource
.
learning_object
.
name
}
author
=
{
resource
.
learning_object
.
author
}
avatar
=
{
resource
.
submitter
.
avatar
}
image
=
{
resource
.
learning_object
.
thumbnail
}
updated_at
=
{
resource
.
learning_object
.
updated_at
}
homologa
=
{
resource
.
status
}
title
=
{
resource
?.
name
||
resource
.
learning_object
?
.
name
}
author
=
{
resource
.
publisher
?.
name
||
resource
.
learning_object
?
.
author
}
avatar
=
{
resource
.
publisher
?.
avatar
||
resource
.
submitter
?
.
avatar
}
image
=
{
resource
?.
thumbnail
||
resource
.
learning_object
?
.
thumbnail
}
updated_at
=
{
resource
?.
updated_at
||
resource
.
learning_object
?
.
updated_at
}
homologa
=
{
resource
?
.
status
}
/
>
))}
<
/div
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment