diff --git a/CHANGELOG.md b/CHANGELOG.md index 11e82ef7..da3abb70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 0.0.31 + +## PiMonitor Client SDK Core + +- [[PM124]](https://github.com/picortex/bitframe/issues/124) Removed onUserLoggedIn method from SignInViewModel +- [[PM141]](https://github.com/picortex/bitframe/issues/141) Created a Register business form +- [[PM140]](https://github.com/picortex/bitframe/issues/140) Make the register business form be invitational +- [[PM023]](https://github.com/picortex/bitframe/issues/23) Register a business +- [[PM017]](https://github.com/picortex/bitframe/issues/17) A Monitor can create a business, in his scope + # 0.0.30 ## PiMonitor Client SDK Core diff --git a/bitframe-authentication/services/core/src/commonMain/kotlin/bitframe/authentication/signin/SignInService.kt b/bitframe-authentication/services/core/src/commonMain/kotlin/bitframe/authentication/signin/SignInService.kt index 8de4cb41..27d78f9e 100644 --- a/bitframe-authentication/services/core/src/commonMain/kotlin/bitframe/authentication/signin/SignInService.kt +++ b/bitframe-authentication/services/core/src/commonMain/kotlin/bitframe/authentication/signin/SignInService.kt @@ -14,7 +14,7 @@ import kotlin.js.JsExport abstract class SignInService( open val bus: EventBus, - open val config: ServiceConfig + protected open val config: ServiceConfig ) { val session: Live = Live(Session.Unknown) val currentSession get() = session.value diff --git a/bitframe-client/sdks/test/src/commonMain/kotlin/bitframe/authentication/TestClientConfiguration.kt b/bitframe-client/sdks/test/src/commonMain/kotlin/bitframe/authentication/TestClientConfiguration.kt index 0b7926a7..5c9cbc87 100644 --- a/bitframe-client/sdks/test/src/commonMain/kotlin/bitframe/authentication/TestClientConfiguration.kt +++ b/bitframe-client/sdks/test/src/commonMain/kotlin/bitframe/authentication/TestClientConfiguration.kt @@ -13,17 +13,17 @@ import kotlin.jvm.JvmSynthetic class TestClientConfiguration @JvmOverloads private constructor( override val appId: String, /** The time (in milliseconds) a client would take to simulate fake activity */ - val simulationTime: Int = DEFAULT_SIMULATION_TIME, + val simulationTime: Long = DEFAULT_SIMULATION_TIME, override val scope: CoroutineScope, ) : ClientConfiguration(appId, scope) { companion object { - const val DEFAULT_SIMULATION_TIME = 0 + const val DEFAULT_SIMULATION_TIME: Long = 0 private val cachedConfigs = mutableMapOf() @JvmSynthetic operator fun invoke( appId: String, - simulationTime: Int = DEFAULT_SIMULATION_TIME, + simulationTime: Long = DEFAULT_SIMULATION_TIME, scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default) ): TestClientConfiguration = cachedConfigs.getOrPut(appId) { TestClientConfiguration(appId, simulationTime, scope) @@ -33,7 +33,7 @@ class TestClientConfiguration @JvmOverloads private constructor( @JvmOverloads fun of( appId: String, - simulationTime: Int = DEFAULT_SIMULATION_TIME, + simulationTime: Long = DEFAULT_SIMULATION_TIME, scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default) ) = invoke(appId, simulationTime, scope) diff --git a/bitframe-client/ui/react/src/main/kotlin/bitframe/Bitframe.kt b/bitframe-client/ui/react/src/main/kotlin/bitframe/Bitframe.kt index 7ff2d305..1df4ff36 100644 --- a/bitframe-client/ui/react/src/main/kotlin/bitframe/Bitframe.kt +++ b/bitframe-client/ui/react/src/main/kotlin/bitframe/Bitframe.kt @@ -27,12 +27,12 @@ private fun defaultRenderers( fun RBuilder.Bitframe( client: BitframeService, - routeRenderers: Map = mapOf(), - moduleRenderers: Map = mapOf(), + pages: Map = mapOf(), + modules: Map = mapOf(), version: String ) = browserRouter { - val allRouteRenderers = routeRenderers.toMutableMap().apply { - putAll(defaultRenderers(client, moduleRenderers, version)) + val allRouteRenderers = pages.toMutableMap().apply { + putAll(defaultRenderers(client, modules, version)) } switch { for ((path, renderer) in allRouteRenderers) route(path, render = renderer) diff --git a/bitframe-client/ui/react/src/main/kotlin/bitframe/authentication/signin/SignInPage.kt b/bitframe-client/ui/react/src/main/kotlin/bitframe/authentication/signin/SignInPage.kt index d7da6b70..10bea57e 100644 --- a/bitframe-client/ui/react/src/main/kotlin/bitframe/authentication/signin/SignInPage.kt +++ b/bitframe-client/ui/react/src/main/kotlin/bitframe/authentication/signin/SignInPage.kt @@ -19,12 +19,12 @@ private external interface SignInPageProps : Props { } private val SignInPage = fc { props -> - val viewModel = props.scope.viewModel + val scope = props.scope + val viewModel = scope.viewModel + val useSignInEvent = scope.useSignInEvent val ui = useViewModelState(viewModel) - useEffectOnce { - viewModel.onUserLoggedIn { _, _ -> - props.history.push("/panel") - } + useSignInEvent { + props.history.push("/panel") } styledDiv { diff --git a/bitframe-client/viewmodels/src/commonMain/kotlin/bitframe/authentication/signin/SignInViewModel.kt b/bitframe-client/viewmodels/src/commonMain/kotlin/bitframe/authentication/signin/SignInViewModel.kt index 74ed5676..a542d966 100644 --- a/bitframe-client/viewmodels/src/commonMain/kotlin/bitframe/authentication/signin/SignInViewModel.kt +++ b/bitframe-client/viewmodels/src/commonMain/kotlin/bitframe/authentication/signin/SignInViewModel.kt @@ -1,9 +1,5 @@ -@file:JsExport - package bitframe.authentication.signin -import bitframe.authentication.spaces.Space -import bitframe.authentication.users.User import bitframe.presenters.feedbacks.FormFeedback.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay @@ -20,8 +16,6 @@ class SignInViewModel( private val service: SignInService ) : ViewModel(SignInState(SignInFormFields(), null)) { - private var loginListener: ((User, Space) -> Unit)? = null - private val recoveryTime = 3000 val console = logger() @@ -30,10 +24,6 @@ class SignInViewModel( is SignInIntent.Submit -> signIn(i) } - fun onUserLoggedIn(listener: (User, Space) -> Unit) { - loginListener = listener - } - private fun CoroutineScope.signIn(i: SignInIntent.Submit) = launch { val state = ui.value.copy(status = Loading("Signing you in, please wait . . .")) flow { @@ -42,12 +32,8 @@ class SignInViewModel( if (conundrum.spaces.size > 1) { console.warn("User has more than one Space, ") emit(state.copy(status = Success("Logged in successfully"))) - loginListener?.invoke(conundrum.user, conundrum.spaces.first()) } else { - val user = conundrum.user - val account = conundrum.spaces.first() emit(state.copy(status = Success("Logged in successfully"))) - loginListener?.invoke(user, account) } }.catch { emit(state.copy(status = Failure(it))) diff --git a/bitframe-client/viewmodels/src/jsMain/kotlin/bitframe/authentication/signin/exports/SignInScope.kt b/bitframe-client/viewmodels/src/jsMain/kotlin/bitframe/authentication/signin/exports/SignInScope.kt index 949f5ff8..66ece728 100644 --- a/bitframe-client/viewmodels/src/jsMain/kotlin/bitframe/authentication/signin/exports/SignInScope.kt +++ b/bitframe-client/viewmodels/src/jsMain/kotlin/bitframe/authentication/signin/exports/SignInScope.kt @@ -3,15 +3,13 @@ package bitframe.authentication.signin.exports -import bitframe.authentication.signin.Session -import bitframe.authentication.signin.SignInIntent -import bitframe.authentication.signin.SignInService -import bitframe.authentication.signin.SignInViewModel +import bitframe.authentication.signin.* import useEventHandler +import viewmodel.ViewModel class SignInScope(service: SignInService) { - val viewModel by lazy { SignInViewModel(service) } + val viewModel: ViewModel by lazy { SignInViewModel(service) } val submit = { cred: SignInCredentials -> viewModel.post(SignInIntent.Submit(cred.toSignInCredentials())) diff --git a/bitframe-daos/test/src/commonMain/kotlin/bitframe/daos/config/InMemoryDaoConfig.kt b/bitframe-daos/test/src/commonMain/kotlin/bitframe/daos/config/InMemoryDaoConfig.kt index 60d851b6..5255d279 100644 --- a/bitframe-daos/test/src/commonMain/kotlin/bitframe/daos/config/InMemoryDaoConfig.kt +++ b/bitframe-daos/test/src/commonMain/kotlin/bitframe/daos/config/InMemoryDaoConfig.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.SupervisorJob import kotlin.jvm.JvmField open class InMemoryDaoConfig( - val simulationTime: Int, + val simulationTime: Long, override val scope: CoroutineScope = CoroutineScope(SupervisorJob()) ) : DaoConfig { companion object { diff --git a/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/BooleanInputField.kt b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/BooleanInputField.kt new file mode 100644 index 00000000..43594de7 --- /dev/null +++ b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/BooleanInputField.kt @@ -0,0 +1,12 @@ +@file:JsExport + +package bitframe.presenters.fields + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +@Serializable +data class BooleanInputField( + val label: String, + var value: Boolean? = null +) \ No newline at end of file diff --git a/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt index 55e65dc4..11904dcd 100644 --- a/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt +++ b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt @@ -6,14 +6,18 @@ import kotlin.js.JsExport import kotlin.js.JsName data class DropDownInputField( - val options: List