Commit 11ce66ef authored by Darya Rednikina's avatar Darya Rednikina
Browse files

It compiles! But shows only `Login` page for now

parent e602c364
......@@ -5143,6 +5143,12 @@ var $author$project$Main$LoginMsg = function (a) {
var $author$project$Main$LoginPage = function (a) {
return {$: 'LoginPage', a: a};
};
var $author$project$Main$RegisterMsg = function (a) {
return {$: 'RegisterMsg', a: a};
};
var $author$project$Main$RegisterPage = function (a) {
return {$: 'RegisterPage', a: a};
};
var $elm$core$Platform$Cmd$batch = _Platform_batch;
var $author$project$Login$Form = F2(
function (email, password) {
......@@ -5159,21 +5165,43 @@ var $author$project$Login$init = _Utils_Tuple2(
_List_Nil,
A2($author$project$Login$Form, '', '')),
$elm$core$Platform$Cmd$none);
var $author$project$Register$Form = F4(
function (login, email, name, password) {
return {email: email, login: login, name: name, password: password};
});
var $author$project$Register$Model = F2(
function (problems, form) {
return {form: form, problems: problems};
});
var $author$project$Register$init = _Utils_Tuple2(
A2(
$author$project$Register$Model,
_List_Nil,
A4($author$project$Register$Form, '', '', '', '')),
$elm$core$Platform$Cmd$none);
var $elm$core$Platform$Cmd$map = _Platform_map;
var $author$project$Main$initCurrentPage = function (_v0) {
var model = _v0.a;
var existingCmds = _v0.b;
var _v1 = function () {
var _v2 = model.route;
if (_v2.$ === 'NotFound') {
return _Utils_Tuple2($author$project$Main$NotFoundPage, $elm$core$Platform$Cmd$none);
} else {
var _v3 = $author$project$Login$init;
var pageModel = _v3.a;
var pageCmds = _v3.b;
return _Utils_Tuple2(
$author$project$Main$LoginPage(pageModel),
A2($elm$core$Platform$Cmd$map, $author$project$Main$LoginMsg, pageCmds));
switch (_v2.$) {
case 'NotFound':
return _Utils_Tuple2($author$project$Main$NotFoundPage, $elm$core$Platform$Cmd$none);
case 'Login':
var _v3 = $author$project$Login$init;
var pageModel = _v3.a;
var pageCmds = _v3.b;
return _Utils_Tuple2(
$author$project$Main$LoginPage(pageModel),
A2($elm$core$Platform$Cmd$map, $author$project$Main$LoginMsg, pageCmds));
default:
var _v4 = $author$project$Register$init;
var pageModel = _v4.a;
var pageCmds = _v4.b;
return _Utils_Tuple2(
$author$project$Main$RegisterPage(pageModel),
A2($elm$core$Platform$Cmd$map, $author$project$Main$RegisterMsg, pageCmds));
}
}();
var currPage = _v1.a;
......@@ -5188,6 +5216,7 @@ var $author$project$Main$initCurrentPage = function (_v0) {
};
var $author$project$Route$NotFound = {$: 'NotFound'};
var $author$project$Route$Login = {$: 'Login'};
var $author$project$Route$Register = {$: 'Register'};
var $elm$url$Url$Parser$Parser = function (a) {
return {$: 'Parser', a: a};
};
......@@ -5292,6 +5321,10 @@ var $author$project$Route$matchRoute = $elm$url$Url$Parser$oneOf(
A2($elm$url$Url$Parser$map, $author$project$Route$Login, $elm$url$Url$Parser$top),
A2(
$elm$url$Url$Parser$map,
$author$project$Route$Register,
$elm$url$Url$Parser$s('register')),
A2(
$elm$url$Url$Parser$map,
$author$project$Route$Login,
$elm$url$Url$Parser$s('login'))
]));
......@@ -6032,51 +6065,57 @@ var $author$project$Login$update = F2(
var $author$project$Main$update = F2(
function (msg, model) {
var _v0 = _Utils_Tuple2(msg, model.page);
switch (_v0.a.$) {
case 'LoginMsg':
if (_v0.b.$ === 'LoginPage') {
var loginMsg = _v0.a.a;
var m = _v0.b.a;
var _v1 = A2($author$project$Login$update, loginMsg, m);
var updatedPageModel = _v1.a;
var updatedCmd = _v1.b;
var m1 = _Utils_Tuple2(
_Utils_update(
_v0$3:
while (true) {
switch (_v0.a.$) {
case 'LoginMsg':
if (_v0.b.$ === 'LoginPage') {
var loginMsg = _v0.a.a;
var m = _v0.b.a;
var _v1 = A2($author$project$Login$update, loginMsg, m);
var updatedPageModel = _v1.a;
var updatedCmd = _v1.b;
var m1 = _Utils_Tuple2(
_Utils_update(
model,
{
page: $author$project$Main$LoginPage(updatedPageModel)
}),
A2($elm$core$Platform$Cmd$map, $author$project$Main$LoginMsg, updatedCmd));
return m1;
} else {
break _v0$3;
}
case 'LinkClicked':
var urlReq = _v0.a.a;
if (urlReq.$ === 'Internal') {
var url = urlReq.a;
return _Utils_Tuple2(
model,
{
page: $author$project$Main$LoginPage(updatedPageModel)
}),
A2($elm$core$Platform$Cmd$map, $author$project$Main$LoginMsg, updatedCmd));
return m1;
} else {
return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none);
}
case 'LinkClicked':
var urlReq = _v0.a.a;
if (urlReq.$ === 'Internal') {
var url = urlReq.a;
return _Utils_Tuple2(
model,
A2(
$elm$browser$Browser$Navigation$pushUrl,
model.navKey,
$elm$url$Url$toString(url)));
} else {
var url = urlReq.a;
return _Utils_Tuple2(
model,
$elm$browser$Browser$Navigation$load(url));
}
default:
var url = _v0.a.a;
var newRoute = $author$project$Route$parseUrl(url);
return $author$project$Main$initCurrentPage(
_Utils_Tuple2(
_Utils_update(
A2(
$elm$browser$Browser$Navigation$pushUrl,
model.navKey,
$elm$url$Url$toString(url)));
} else {
var url = urlReq.a;
return _Utils_Tuple2(
model,
{route: newRoute}),
$elm$core$Platform$Cmd$none));
$elm$browser$Browser$Navigation$load(url));
}
case 'UrlChanged':
var url = _v0.a.a;
var newRoute = $author$project$Route$parseUrl(url);
return $author$project$Main$initCurrentPage(
_Utils_Tuple2(
_Utils_update(
model,
{route: newRoute}),
$elm$core$Platform$Cmd$none));
default:
break _v0$3;
}
}
return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none);
});
var $elm$virtual_dom$VirtualDom$map = _VirtualDom_map;
var $elm$html$Html$map = $elm$virtual_dom$VirtualDom$map;
......@@ -6108,6 +6147,28 @@ var $elm$html$Html$Attributes$href = function (url) {
'href',
_VirtualDom_noJavaScriptUri(url));
};
var $author$project$Route$routeToPieces = function (page) {
switch (page.$) {
case 'Login':
return _List_fromArray(
['login']);
case 'Register':
return _List_fromArray(
['register']);
default:
return _List_Nil;
}
};
var $author$project$Route$routeToString = function (page) {
return '#/' + A2(
$elm$core$String$join,
'/',
$author$project$Route$routeToPieces(page));
};
var $author$project$Route$href = function (targetRoute) {
return $elm$html$Html$Attributes$href(
$author$project$Route$routeToString(targetRoute));
};
var $elm$html$Html$p = _VirtualDom_node('p');
var $elm$html$Html$ul = _VirtualDom_node('ul');
var $author$project$Login$EnteredEmail = function (a) {
......@@ -6313,7 +6374,7 @@ var $author$project$Login$view = function (model) {
$elm$html$Html$a,
_List_fromArray(
[
$elm$html$Html$Attributes$href('/register')
$author$project$Route$href($author$project$Route$Register)
]),
_List_fromArray(
[
......@@ -6333,16 +6394,204 @@ var $author$project$Login$view = function (model) {
]))
]));
};
var $author$project$Register$EnteredEmail = function (a) {
return {$: 'EnteredEmail', a: a};
};
var $author$project$Register$EnteredLogin = function (a) {
return {$: 'EnteredLogin', a: a};
};
var $author$project$Register$EnteredName = function (a) {
return {$: 'EnteredName', a: a};
};
var $author$project$Register$EnteredPassword = function (a) {
return {$: 'EnteredPassword', a: a};
};
var $author$project$Register$SubmittedForm = {$: 'SubmittedForm'};
var $author$project$Register$viewForm = function (form) {
return A2(
$elm$html$Html$form,
_List_fromArray(
[
$elm$html$Html$Events$onSubmit($author$project$Register$SubmittedForm)
]),
_List_fromArray(
[
A2(
$elm$html$Html$fieldset,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-group')
]),
_List_fromArray(
[
A2(
$elm$html$Html$input,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-control form-control-lg'),
$elm$html$Html$Attributes$type_('name'),
$elm$html$Html$Attributes$placeholder('Name'),
$elm$html$Html$Events$onInput($author$project$Register$EnteredName),
$elm$html$Html$Attributes$value(form.name)
]),
_List_Nil)
])),
A2(
$elm$html$Html$fieldset,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-group')
]),
_List_fromArray(
[
A2(
$elm$html$Html$input,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-control form-control-lg'),
$elm$html$Html$Attributes$type_('login'),
$elm$html$Html$Attributes$placeholder('Login'),
$elm$html$Html$Events$onInput($author$project$Register$EnteredLogin),
$elm$html$Html$Attributes$value(form.login)
]),
_List_Nil)
])),
A2(
$elm$html$Html$fieldset,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-group')
]),
_List_fromArray(
[
A2(
$elm$html$Html$input,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-control form-control-lg'),
$elm$html$Html$Attributes$placeholder('Email'),
$elm$html$Html$Events$onInput($author$project$Register$EnteredEmail),
$elm$html$Html$Attributes$value(form.email)
]),
_List_Nil)
])),
A2(
$elm$html$Html$fieldset,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-group')
]),
_List_fromArray(
[
A2(
$elm$html$Html$input,
_List_fromArray(
[
$elm$html$Html$Attributes$class('form-control form-control-lg'),
$elm$html$Html$Attributes$type_('password'),
$elm$html$Html$Attributes$placeholder('Password'),
$elm$html$Html$Events$onInput($author$project$Register$EnteredPassword),
$elm$html$Html$Attributes$value(form.password)
]),
_List_Nil)
])),
A2(
$elm$html$Html$button,
_List_fromArray(
[
$elm$html$Html$Attributes$class('btn btn-lg btn-primary pull-xs-right')
]),
_List_fromArray(
[
$elm$html$Html$text('Sign up')
]))
]));
};
var $author$project$Register$view = function (model) {
return A2(
$elm$html$Html$div,
_List_fromArray(
[
$elm$html$Html$Attributes$class('cred-page')
]),
_List_fromArray(
[
A2(
$elm$html$Html$div,
_List_fromArray(
[
$elm$html$Html$Attributes$class('container page')
]),
_List_fromArray(
[
A2(
$elm$html$Html$div,
_List_fromArray(
[
$elm$html$Html$Attributes$class('row')
]),
_List_fromArray(
[
A2(
$elm$html$Html$div,
_List_fromArray(
[
$elm$html$Html$Attributes$class('col-md-6 offset-md-3 col-xs-12')
]),
_List_fromArray(
[
A2(
$elm$html$Html$h1,
_List_fromArray(
[
$elm$html$Html$Attributes$class('text-xs-center')
]),
_List_fromArray(
[
$elm$html$Html$text('Sign up')
])),
A2(
$elm$html$Html$p,
_List_fromArray(
[
$elm$html$Html$Attributes$class('text-xs-center')
]),
_List_fromArray(
[
A2(
$elm$html$Html$a,
_List_fromArray(
[
$author$project$Route$href($author$project$Route$Login)
]),
_List_fromArray(
[
$elm$html$Html$text('Already have an account?')
]))
])),
$author$project$Register$viewForm(model.form)
]))
]))
]))
]));
};
var $author$project$Main$currView = function (model) {
var _v0 = model.page;
if (_v0.$ === 'NotFoundPage') {
return $author$project$Main$notFoundView;
} else {
var pageModel = _v0.a;
return A2(
$elm$html$Html$map,
$author$project$Main$LoginMsg,
$author$project$Login$view(pageModel));
switch (_v0.$) {
case 'NotFoundPage':
return $author$project$Main$notFoundView;
case 'LoginPage':
var pageModel = _v0.a;
return A2(
$elm$html$Html$map,
$author$project$Main$LoginMsg,
$author$project$Login$view(pageModel));
default:
var pageModel = _v0.a;
return A2(
$elm$html$Html$map,
$author$project$Main$RegisterMsg,
$author$project$Register$view(pageModel));
}
};
var $author$project$Main$view = function (model) {
......
......@@ -6,6 +6,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Login exposing (Model)
import Register exposing (Model)
import Route exposing (..)
import Url exposing (Url)
......@@ -24,6 +25,7 @@ type alias Model =
type Page
= NotFoundPage
| LoginPage Login.Model
| RegisterPage Register.Model
......@@ -32,6 +34,7 @@ type Page
type Msg
= LoginMsg Login.Msg
| RegisterMsg Register.Msg
| LinkClicked UrlRequest
| UrlChanged Url
......@@ -102,6 +105,9 @@ currView model =
LoginPage pageModel ->
Login.view pageModel |> Html.map LoginMsg
RegisterPage pageModel ->
Register.view pageModel |> Html.map RegisterMsg
notFoundView : Html msg
notFoundView =
......@@ -150,6 +156,13 @@ initCurrentPage ( model, existingCmds ) =
Login.init
in
( LoginPage pageModel, Cmd.map LoginMsg pageCmds )
Route.Register ->
let
( pageModel, pageCmds ) =
Register.init
in
( RegisterPage pageModel, Cmd.map RegisterMsg pageCmds )
in
( { model | page = currPage }
, Cmd.batch [ existingCmds, mappedCmds ]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment