Skip to content

Commit

Permalink
Fixed organization render avatar on IndexView (#2952)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheshiriks authored May 2, 2024
1 parent 7e126d4 commit e101105
Showing 1 changed file with 7 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.saveourtool.common.entities.OrganizationStatus
import com.saveourtool.common.validation.FrontendCosvRoutes
import com.saveourtool.common.validation.FrontendRoutes
import com.saveourtool.frontend.common.components.basic.renderAvatar
import com.saveourtool.frontend.common.components.basic.renderOrganizationAvatar
import com.saveourtool.frontend.common.utils.*
import com.saveourtool.save.frontend.externals.i18next.useTranslation

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

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

setOrganizations(organizationsNew)

val countVuln: Int = get(
"$apiUrl/vulnerabilities/count-by-user?userName=$it",
jsonHeaders,
loadingHandler = ::loadingHandler,
)
.decodeFromJsonString()

setCountVulnerability(countVuln)
}
}

Expand Down Expand Up @@ -195,7 +187,11 @@ val cardUser: FC<UserInfoAwareProps> = FC { props ->
div {
className = ClassName("col-12 mt-2 pl-4")
val renderImg: ChildrenBuilder.() -> Unit = {
renderAvatar(organization) {
renderOrganizationAvatar(
organization,
errorAvatars = errorAvatars,
setErrorAvatars = { name -> setErrorAvatars(errorAvatars.plus(name)) }
) {
height = 2.rem
width = 2.rem
}
Expand Down Expand Up @@ -230,25 +226,6 @@ val cardUser: FC<UserInfoAwareProps> = FC { props ->
+"${"Your statistics".t()}:"
}
}
div {
className = ClassName("row text-muted border-bottom border-gray mx-3")
div {
className = ClassName("col-9")
p {
+"${"Vulnerabilities".t()}: "
}
}

div {
className = ClassName("col-3")
p {
Link {
to = "/${FrontendRoutes.PROFILE}/${props.userInfo?.name}"
+countVulnerability.toString()
}
}
}
}

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

0 comments on commit e101105

Please sign in to comment.