-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.go
54 lines (40 loc) · 995 Bytes
/
login.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package presenters
import (
"github.com/yolo-sh/cli/internal/features"
)
type LoginViewDataContent struct {
Message string
}
type LoginViewData struct {
Error *ViewableError
Content LoginViewDataContent
}
type LoginViewer interface {
View(LoginViewData)
}
type LoginPresenter struct {
viewableErrorBuilder ViewableErrorBuilder
viewer LoginViewer
}
func NewLoginPresenter(
viewableErrorBuilder ViewableErrorBuilder,
viewer LoginViewer,
) LoginPresenter {
return LoginPresenter{
viewableErrorBuilder: viewableErrorBuilder,
viewer: viewer,
}
}
func (l LoginPresenter) PresentToView(response features.LoginResponse) {
viewData := LoginViewData{}
if response.Error == nil {
viewDataMessage := "Your GitHub account is now connected."
viewData.Content = LoginViewDataContent{
Message: viewDataMessage,
}
l.viewer.View(viewData)
return
}
viewData.Error = l.viewableErrorBuilder.Build(response.Error)
l.viewer.View(viewData)
}