generated from orchestr7/react-kotlin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
151 additions
and
8 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
backend/src/main/kotlin/ru/posidata/backend/controller/RandomController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ru.posidata.backend.controller | ||
|
||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.* | ||
import ru.posidata.backend.service.UserService | ||
|
||
@RestController | ||
@RequestMapping("api") | ||
class RandomController( | ||
private val userService: UserService | ||
) { | ||
@GetMapping("/random") | ||
fun random(): ResponseEntity<Any> { | ||
val randomUser = userService.getRandomUser() | ||
return ResponseEntity.ok(randomUser.toDTO()) | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
backend/src/main/kotlin/ru/posidata/backend/repository/UserRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package ru.posidata.backend.repository | ||
|
||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
import ru.posidata.backend.entity.OurUserEntityFromDb | ||
|
||
@Repository | ||
interface UserRepository : CrudRepository<OurUserEntityFromDb, Long> { | ||
interface UserRepository : JpaRepository<OurUserEntityFromDb, Long> { | ||
fun findByUsername(username: String): OurUserEntityFromDb? | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
frontend/src/jsMain/kotlin/ru/posidata/views/main/LuckyDraw.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package ru.posidata.views.main | ||
|
||
import js.objects.jso | ||
import kotlinx.browser.window | ||
import react.* | ||
import react.dom.html.ReactHTML | ||
import react.dom.html.ReactHTML.button | ||
import react.dom.html.ReactHTML.div | ||
import react.dom.html.ReactHTML.h1 | ||
import ru.posidata.common.UserForSerializationDTO | ||
import ru.posidata.views.utils.externals.particles.Particles | ||
import ru.posidata.views.utils.externals.slotmachine.Slot | ||
import ru.posidata.views.utils.internals.* | ||
import web.cssom.* | ||
|
||
val luckyDrawCard = FC<LuckyDrawProps> { _ -> | ||
val (luckyUserName, setLuckyUserName) = useState<String?>(null) | ||
|
||
val getUser = useDeferredRequest { | ||
val response = get( | ||
url = "${window.location.origin}/api/random", | ||
params = jso<dynamic> {}, | ||
headers = jsonHeaders, | ||
loadingHandler = ::noopLoadingHandler, | ||
responseHandler = ::noopResponseHandler, | ||
) | ||
setLuckyUserName(response.decodeFromJsonString<UserForSerializationDTO>().username) | ||
} | ||
Particles::class.react { | ||
id = "tsparticles" | ||
url = "${window.location.origin}/particles.json" | ||
} | ||
|
||
ReactHTML.div { | ||
className = ClassName("full-width-container") | ||
id = "back" | ||
ReactHTML.div { | ||
className = ClassName("row justify-content-center align-items-center text-center") | ||
style = jso { | ||
minHeight = "100vh".unsafeCast<MinHeight>() | ||
} | ||
|
||
h1 { | ||
className = ClassName(" justify-content-center align-items-center text-center") | ||
style = jso { | ||
fontFamily = "'Inter', sans-serif".unsafeCast<FontFamily>() | ||
fontSize = 200.unsafeCast<FontSize>() | ||
color = "white".unsafeCast<Color>() | ||
} | ||
if (luckyUserName != null) { | ||
Slot { | ||
startValue = "posidata" | ||
value = luckyUserName | ||
speed = 3.0 | ||
duration = 7.0 | ||
} | ||
} | ||
} | ||
|
||
div { | ||
className = ClassName("col-5 zIndex1000") | ||
button { | ||
+"Погнали, разыграем кусок ДСП!" | ||
className = ClassName("btn btn-outline-info zIndex1000") | ||
onClick = { | ||
getUser() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
external interface LuckyDrawProps : Props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
frontend/src/jsMain/kotlin/ru/posidata/views/utils/externals/slotmachine/LuckyDraw.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@file:JsModule("react-slot-counter") | ||
@file:JsNonModule | ||
|
||
package ru.posidata.views.utils.externals.slotmachine | ||
|
||
import react.* | ||
|
||
@JsName("default") // Ensures you're importing the default export | ||
external val Slot: FC<SlotProps> // Declare the component | ||
|
||
// External Props definition that maps to your TypeScript interface | ||
external interface SlotProps : Props { | ||
var index: Int | ||
var isNew: Boolean? | ||
var charClassName: String? | ||
var numbersRef: RefObject<dynamic> | ||
var active: Boolean | ||
var isChanged: Boolean | ||
var effectiveDuration: Double | ||
var delay: Double | ||
var value: dynamic | ||
var startValue: dynamic? | ||
var disableStartValue: Boolean? | ||
var dummyList: Array<dynamic> | ||
var hasSequentialDummyList: Boolean? | ||
var hasInfiniteList: Boolean? | ||
var valueClassName: String? | ||
var numberSlotClassName: String? | ||
var numberClassName: String? | ||
var reverse: Boolean? | ||
var sequentialAnimationMode: Boolean | ||
var useMonospaceWidth: Boolean | ||
var maxNumberWidth: Int? | ||
var onFontHeightChange: ((Int) -> Unit)? | ||
var speed: Double | ||
var duration: Double | ||
} |
1 change: 0 additions & 1 deletion
1
frontend/src/jsMain/kotlin/ru/posidata/views/utils/externals/telegram/ReactTelegramAuth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@file:JsModule("react-telegram-auth") | ||
@file:JsNonModule | ||
|
||
package ru.posidata.views.utils.externals.telegram | ||
|
||
|
1 change: 0 additions & 1 deletion
1
frontend/src/jsMain/kotlin/ru/posidata/views/utils/externals/telegram/TLoginButtonProps.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@file:JsModule("react-telegram-auth") | ||
@file:JsNonModule | ||
|
||
package ru.posidata.views.utils.externals.telegram | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2877,6 +2877,11 @@ [email protected], react-router@^6.23.1: | |
dependencies: | ||
"@remix-run/router" "1.16.1" | ||
|
||
[email protected]: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/react-slot-counter/-/react-slot-counter-3.0.1.tgz#7b2becdbea1f8c83eb754371d1bd65b287ef3648" | ||
integrity sha512-+NwzRrZ+zWErP/8nz+0Y/imtOcMDr1A2Gv8CfzXNRW/zXaxNPMpZQdWeJAX/HiSqaeGc+jxKqKscoMN101NYDg== | ||
|
||
[email protected]: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/react-telegram-auth/-/react-telegram-auth-1.0.4.tgz#76443a3930497de7ab03a24d791e03aeeac47a5c" | ||
|