-
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.
Merge pull request #161 from picortex/master-dev-anderson
Master dev anderson
- Loading branch information
Showing
43 changed files
with
385 additions
and
76 deletions.
There are no files selected for viewing
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
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
12 changes: 12 additions & 0 deletions
12
bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/BooleanInputField.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,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 | ||
) |
18 changes: 8 additions & 10 deletions
18
...nitor-client/browser/react/src/jsMain/kotlin/pimonitor/evaluation/business/AddBusiness.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,41 +1,39 @@ | ||
package pimonitor.evaluation.business | ||
|
||
import logging.console | ||
import pimonitor.PiMonitorService | ||
import pimonitor.evaluation.business.forms.CreateBusinessState | ||
import pimonitor.evaluation.business.exports.CreateBusinessScope | ||
import pimonitor.evaluation.business.forms.CreateBusinessState.* | ||
import react.Props | ||
import react.RBuilder | ||
import react.fc | ||
import react.useEffectOnce | ||
import reakt.ErrorBox | ||
import reakt.LoadingBox | ||
import reakt.SuccessBox | ||
import useViewModelState | ||
import pimonitor.evaluation.business.forms.CreateBusinessIntent as Intent | ||
|
||
private external interface AddBusinessProps : Props { | ||
var uid: String? | ||
var scope: AddBusinessScope | ||
var scope: CreateBusinessScope | ||
} | ||
|
||
private val AddBusiness = fc<AddBusinessProps> { props -> | ||
val scope = props.scope | ||
val vm = scope.viewModel | ||
useEffectOnce { | ||
scope.showForm(props.uid) | ||
} | ||
useEffectOnce { scope.showForm(props.uid) } | ||
when (val state = useViewModelState(vm)) { | ||
is Loading -> LoadingBox(state.message) | ||
is Form -> CreateBusinessForm( | ||
state = state, | ||
onSubmit = { | ||
console.log(it) | ||
} | ||
onSubmit = { vm.post(Intent.SubmitForm(it)) } | ||
) | ||
is Success -> SuccessBox(state.message) | ||
is Failure -> ErrorBox(state.cause) | ||
} | ||
} | ||
|
||
internal fun RBuilder.AddBusiness(service: PiMonitorService, uid: String? = null) = child(AddBusiness) { | ||
attrs.scope = AddBusinessScope(service) | ||
attrs.scope = CreateBusinessScope(service) | ||
attrs.uid = uid | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,18 @@ class AddBusinessTest : AcceptanceTest() { | |
name = "Jane Doe", email = "[email protected]", password = "janedoe" | ||
) | ||
val dashboard = openSignUpScreen().signUp(params).expectToBeSigningUp() | ||
val details = CreateMonitoredBusinessParams( | ||
businessName = "PiCortex", | ||
contactName = "Mohammed Majapa", | ||
contactEmail = "[email protected]" | ||
) | ||
val businesses = dashboard.selectBusinesses() | ||
businesses.clickCreateButton().apply { | ||
enter(details) | ||
submitByPressingEnter() | ||
for (i in 1..5) { | ||
val details = CreateMonitoredBusinessParams( | ||
businessName = "PiCortex - $i", | ||
contactName = "Mohammed Majapa - $i", | ||
contactEmail = "mmajapa$i@gmail.com" | ||
) | ||
businesses.clickCreateButton().apply { | ||
enter(details) | ||
submitByPressingEnter() | ||
} | ||
businesses.expectToHaveBusinessWithName(details.businessName) | ||
} | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
...onitor-client/sdks/core/src/jsMain/kotlin/pimonitor/evaluation/business/exports/Params.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,9 @@ | ||
@file:JsExport | ||
|
||
package pimonitor.evaluation.business.exports | ||
|
||
external interface CreateBusinessFormParams { | ||
var businessName: String | ||
var contactName: String | ||
var contactEmail: String | ||
} |
7 changes: 7 additions & 0 deletions
7
...r-client/sdks/core/src/jsMain/kotlin/pimonitor/evaluation/business/exports/ParamsUtils.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,7 @@ | ||
package pimonitor.evaluation.business.exports | ||
|
||
import pimonitor.monitored.CreateMonitoredBusinessParams | ||
|
||
fun CreateBusinessFormParams.toParams() = CreateMonitoredBusinessParams( | ||
businessName, contactName, contactEmail | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package pimonitor.evaluation.business.forms | ||
|
||
import bitframe.presenters.fields.BooleanInputField | ||
import bitframe.presenters.fields.ButtonInputField | ||
import bitframe.presenters.fields.TextInputField | ||
import pimonitor.monitors.Monitor | ||
import pimonitor.evaluation.business.forms.CreateBusinessIntent as Intent | ||
|
||
internal fun AddBusinessFormFields() = CreateBusinessFields( | ||
inviterIntroduction = null, | ||
|
@@ -19,6 +21,10 @@ internal fun AddBusinessFormFields() = CreateBusinessFields( | |
label = "Contact Email", | ||
hint = "[email protected]" | ||
), | ||
sendInvite = BooleanInputField( | ||
label = "Ask to share reports", | ||
value = true | ||
), | ||
submitButton = ButtonInputField(text = "Submit") | ||
) | ||
|
||
|
@@ -37,5 +43,13 @@ internal fun InviteBusinessFormFields(inviter: Monitor) = CreateBusinessFields( | |
label = "Your Email", | ||
hint = "[email protected]" | ||
), | ||
sendInvite = null, | ||
submitButton = ButtonInputField(text = "Submit") | ||
) | ||
|
||
internal fun CreateBusinessFields.copy(i: Intent.SubmitForm) = copy( | ||
businessName = businessName.copy(value = i.params.businessName), | ||
contactName = contactName.copy(value = i.params.contactName), | ||
contactEmail = contactEmail.copy(value = i.params.contactEmail), | ||
sendInvite = sendInvite?.copy(value = i.params.sendInvite) | ||
) |
3 changes: 3 additions & 0 deletions
3
...ks/full/src/commonMain/kotlin/pimonitor/evaluation/business/forms/CreateBusinessIntent.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,8 @@ | ||
package pimonitor.evaluation.business.forms | ||
|
||
import pimonitor.monitored.CreateMonitoredBusinessParams | ||
|
||
sealed class CreateBusinessIntent { | ||
data class ShowForm(val inviteId: String?) : CreateBusinessIntent() | ||
data class SubmitForm(val params: CreateMonitoredBusinessParams) : CreateBusinessIntent() | ||
} |
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
12 changes: 12 additions & 0 deletions
12
...ull/src/commonMain/kotlin/pimonitor/evaluation/business/forms/CreateBusinessStateUtils.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,12 @@ | ||
@file:JsExport | ||
|
||
package pimonitor.evaluation.business.forms | ||
|
||
import kotlin.js.JsExport | ||
import pimonitor.evaluation.business.forms.CreateBusinessIntent as Intent | ||
|
||
internal fun CreateBusinessState.copy(i: Intent.SubmitForm) = if (this is CreateBusinessState.Form) { | ||
CreateBusinessState.Form(fields = fields.copy(i), status) | ||
} else { | ||
this | ||
} |
Oops, something went wrong.