Skip to content

Commit e101105

Browse files
authored
Fixed organization render avatar on IndexView (#2952)
1 parent 7e126d4 commit e101105

File tree

1 file changed

+7
-30
lines changed
  • save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index

1 file changed

+7
-30
lines changed

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/CardUser.kt

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.saveourtool.common.entities.OrganizationStatus
99
import com.saveourtool.common.validation.FrontendCosvRoutes
1010
import com.saveourtool.common.validation.FrontendRoutes
1111
import com.saveourtool.frontend.common.components.basic.renderAvatar
12+
import com.saveourtool.frontend.common.components.basic.renderOrganizationAvatar
1213
import com.saveourtool.frontend.common.utils.*
1314
import com.saveourtool.save.frontend.externals.i18next.useTranslation
1415

@@ -42,7 +43,7 @@ import kotlinx.datetime.toLocalDateTime
4243
val cardUser: FC<UserInfoAwareProps> = FC { props ->
4344
val (t) = useTranslation("index")
4445
val (organizations, setOrganizations) = useState(emptyList<OrganizationDto>())
45-
val (countVulnerability, setCountVulnerability) = useState(0)
46+
val (errorAvatars, setErrorAvatars) = useState(emptySet<String>())
4647
val navigate = useNavigate()
4748

4849
@Suppress("TOO_MANY_LINES_IN_LAMBDA")
@@ -56,15 +57,6 @@ val cardUser: FC<UserInfoAwareProps> = FC { props ->
5657
.decodeFromJsonString()
5758

5859
setOrganizations(organizationsNew)
59-
60-
val countVuln: Int = get(
61-
"$apiUrl/vulnerabilities/count-by-user?userName=$it",
62-
jsonHeaders,
63-
loadingHandler = ::loadingHandler,
64-
)
65-
.decodeFromJsonString()
66-
67-
setCountVulnerability(countVuln)
6860
}
6961
}
7062

@@ -195,7 +187,11 @@ val cardUser: FC<UserInfoAwareProps> = FC { props ->
195187
div {
196188
className = ClassName("col-12 mt-2 pl-4")
197189
val renderImg: ChildrenBuilder.() -> Unit = {
198-
renderAvatar(organization) {
190+
renderOrganizationAvatar(
191+
organization,
192+
errorAvatars = errorAvatars,
193+
setErrorAvatars = { name -> setErrorAvatars(errorAvatars.plus(name)) }
194+
) {
199195
height = 2.rem
200196
width = 2.rem
201197
}
@@ -230,25 +226,6 @@ val cardUser: FC<UserInfoAwareProps> = FC { props ->
230226
+"${"Your statistics".t()}:"
231227
}
232228
}
233-
div {
234-
className = ClassName("row text-muted border-bottom border-gray mx-3")
235-
div {
236-
className = ClassName("col-9")
237-
p {
238-
+"${"Vulnerabilities".t()}: "
239-
}
240-
}
241-
242-
div {
243-
className = ClassName("col-3")
244-
p {
245-
Link {
246-
to = "/${FrontendRoutes.PROFILE}/${props.userInfo?.name}"
247-
+countVulnerability.toString()
248-
}
249-
}
250-
}
251-
}
252229

253230
div {
254231
className = ClassName("row text-muted border-bottom border-gray mx-3 mt-2")

0 commit comments

Comments
 (0)