Skip to content

Commit

Permalink
first command conversion since switching the sdk over - went well
Browse files Browse the repository at this point in the history
  • Loading branch information
robertfmurdock committed Jul 15, 2023
1 parent 7e27d36 commit 3a70bf5
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.zegreatrob.coupling.client.components.party
import com.benasher44.uuid.uuid4
import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.SavePartyCommand
import com.zegreatrob.coupling.action.party.perform
import com.zegreatrob.coupling.client.components.DispatchFunc
import com.zegreatrob.coupling.client.components.Paths
import com.zegreatrob.coupling.client.components.useForm
Expand Down Expand Up @@ -34,7 +35,15 @@ val PartyConfig by nfc<PartyConfigProps<*>> { (party, commandFunc) ->
val (redirectUrl, setRedirectUrl) = useState<String?>(null)
val redirectToPartyList = { setRedirectUrl(Paths.partyList()) }
val onSave = commandFunc({ SavePartyCommand(updatedParty) }, { redirectToPartyList() })
val onDelete = if (isNew) null else commandFunc({ DeletePartyCommand(party.id) }, { redirectToPartyList() })
val onDelete = if (isNew) {
null
} else {
commandFunc(
commandFunc = { DeletePartyCommand(party.id) },
fireFunc = ::perform,
response = { redirectToPartyList() },
)
}

if (redirectUrl != null) {
Navigate { to = redirectUrl }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.zegreatrob.coupling.e2e.test

import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.fire
import com.zegreatrob.coupling.model.Record
import com.zegreatrob.coupling.model.party.PartyDetails
import com.zegreatrob.coupling.sdk.CouplingSdkDispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package com.zegreatrob.coupling.action.party

import com.zegreatrob.coupling.action.VoidResult
import com.zegreatrob.coupling.model.party.PartyId
import com.zegreatrob.testmints.action.async.SimpleSuspendAction

data class DeletePartyCommand(val partyId: PartyId) : SimpleSuspendAction<DeletePartyCommand.Dispatcher, VoidResult> {
override val performFunc = link(Dispatcher::perform)
import com.zegreatrob.testmints.action.annotation.MintAction

@MintAction
data class DeletePartyCommand(val partyId: PartyId) {
interface Dispatcher {
suspend fun perform(command: DeletePartyCommand): VoidResult
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package com.zegreatrob.coupling.sdk

import com.benasher44.uuid.uuid4
import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.fire
import com.zegreatrob.coupling.sdk.gql.graphQuery
import com.zegreatrob.testmints.action.ActionCannon
import io.ktor.client.HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.zegreatrob.coupling.action.pairassignmentdocument.SavePairAssignments
import com.zegreatrob.coupling.action.pairassignmentdocument.fire
import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.SavePartyCommand
import com.zegreatrob.coupling.action.party.fire
import com.zegreatrob.coupling.model.PartyRecord
import com.zegreatrob.coupling.model.data
import com.zegreatrob.coupling.model.element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.benasher44.uuid.uuid4
import com.zegreatrob.coupling.action.CommandResult
import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.SavePartyCommand
import com.zegreatrob.coupling.action.party.fire
import com.zegreatrob.coupling.action.player.DeletePlayerCommand
import com.zegreatrob.coupling.action.player.SavePlayerCommand
import com.zegreatrob.coupling.model.player.Player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.zegreatrob.coupling.action.pairassignmentdocument.SpinCommand
import com.zegreatrob.coupling.action.pairassignmentdocument.fire
import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.SavePartyCommand
import com.zegreatrob.coupling.action.party.fire
import com.zegreatrob.coupling.action.pin.SavePinCommand
import com.zegreatrob.coupling.action.pin.fire
import com.zegreatrob.coupling.action.player.SavePlayerCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.zegreatrob.coupling.action.pairassignmentdocument.SavePairAssignments
import com.zegreatrob.coupling.action.pairassignmentdocument.fire
import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.SavePartyCommand
import com.zegreatrob.coupling.action.party.fire
import com.zegreatrob.coupling.json.JsonCouplingSocketMessage
import com.zegreatrob.coupling.json.JsonMessage
import com.zegreatrob.coupling.json.fromJsonString
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package com.zegreatrob.coupling.server.entity.party

import com.zegreatrob.coupling.action.party.DeletePartyCommand
import com.zegreatrob.coupling.action.party.perform
import com.zegreatrob.coupling.json.DeletePartyInput
import com.zegreatrob.coupling.server.external.graphql.Resolver
import com.zegreatrob.coupling.server.graphql.DispatcherProviders.authorizedPartyDispatcher
import com.zegreatrob.coupling.server.graphql.dispatch
import com.zegreatrob.coupling.server.graphql.dispatchAction
import kotlinx.serialization.json.JsonNull

val deletePartyResolver: Resolver = dispatch(
val deletePartyResolver: Resolver = dispatchAction(
dispatcherFunc = { request, _: JsonNull, args ->
authorizedPartyDispatcher(
context = request,
partyId = args.partyId.value,
)
},
queryFunc = { _, input: DeletePartyInput -> DeletePartyCommand(input.partyId) },
commandFunc = { _, input: DeletePartyInput -> DeletePartyCommand(input.partyId) },
fireFunc = ::perform,
toSerializable = { true },
)

0 comments on commit 3a70bf5

Please sign in to comment.