(state: InviteState, action: InviteAction)
| 120 | | { type: "reset" }; |
| 121 | |
| 122 | function inviteReducer(state: InviteState, action: InviteAction): InviteState { |
| 123 | return Match.value(action).pipe( |
| 124 | Match.discriminator("type")("setEmail", (a) => ({ |
| 125 | ...state, |
| 126 | email: a.email, |
| 127 | })), |
| 128 | Match.discriminator("type")("setRole", (a) => ({ |
| 129 | ...state, |
| 130 | roleSlug: a.roleSlug, |
| 131 | })), |
| 132 | Match.discriminator("type")("send", () => ({ |
| 133 | ...state, |
| 134 | status: "sending" as const, |
| 135 | })), |
| 136 | Match.discriminator("type")("error", (a) => ({ |
| 137 | ...state, |
| 138 | status: "error" as const, |
| 139 | errorMessage: a.message, |
| 140 | })), |
| 141 | Match.discriminator("type")("reset", () => initialInviteState), |
| 142 | Match.exhaustive, |
| 143 | ); |
| 144 | } |
| 145 | |
| 146 | // Generic fallback when the server gave no typed reason (a transient failure |
| 147 | // the admin genuinely can retry). A seat-limit refusal carries its own message. |
nothing calls this directly
no outgoing calls
no test coverage detected