A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: c15a749fd53bcf6375544082a2cfef2a7e32f653 (5978 bytes)[doc][blame][raw]
1
import {$lang, $route, http} from '../utils.js';2
import VTab from '../component/tab.js';3
import VSelect from '../component/select.js';4
import VButton from '../element/button.js';6
export default {7
props: ['state'],8
data() {9
return {10
name: '',11
language: 'en',12
token: '',13
method: null14
};15
},16
components: {17
VTab,18
VSelect,19
VButton20
},21
methods: {22
$lang,23
$route,24
async register() {25
try {26
localStorage.removeItem('verbal-token');27
const device = await http`post::/api/account`({28
name: this.name,29
language: this.language30
});31
localStorage.setItem('verbal-token', device.uid);32
this.state.app.init();33
$route('/');34
}35
catch(err) {36
console.error(err);37
}38
},39
async login() {40
try {41
localStorage.setItem('verbal-token', this.token);42
await http`get::/api/account`();43
this.state.app.init();44
$route('/');45
}46
catch(err) {47
localStorage.removeItem('verbal-token');48
console.error(err);49
}50
}51
},52
template: `53
<v-tab id="auth" :tab="state.tab">54
<div class="flex flex-col items-center justify-center h-screen min-h-screen">55
<div v-if="method === null">56
<h3 class="text-white text-[34px] font-bold pb-4 -mt-14 text-center">{{$lang('global.brand')}}</h3>57
<p class="text-md text-gray-400 text-center pb-12 px-4">{{$lang('global.slogan')}}</p>58
<div class="flex flex-col gap-5 w-full px-4">59
<button60
class="w-full h-[52px] px-4 text-md bg-zinc-100 hover:bg-zinc-300 text-zinc-900 rounded-md outline-none"61
@click="method = 'register'"62
>63
Create an account64
</button>65
<button66
class="w-full h-[52px] px-4 text-md bg-zinc-900 hover:bg-zinc-800 text-zinc-100 rounded-md outline-none"67
@click="method = 'login'"68
>69
Log In70
</button>71
</div>72
</div>73
<div v-if="method === 'register'" class="w-full flex flex-col gap-5 -mt-12">74
<v-button75
icon="arrow-left"76
title="Back"77
@click="method = null"78
class="self-start"79
>80
</v-button>81
<h3 class="text-white text-[24px] font-bold pb-4 px-4 sm:pt-0">Create an account</h3>82
<div class="flex flex-col gap-1 w-full px-4">83
<label for="username" class="text-white text-lg">Choose your username</label>84
<input85
v-model="name"86
id="username"87
type="text"88
maxlength="20"89
spellcheck="false"90
autocomplete="off"91
class="rounded-md w-full h-[52px] px-4 mt-2 text-md bg-zinc-900 text-white placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"92
>93
</div>94
<div class="flex flex-col gap-1 w-full px-4">95
<label for="language" class="text-white text-lg">Select language</label>96
<v-select97
id="language"98
v-model="language"99
class="mt-2"100
>101
<option value="en">English</option>102
<option value="de">Deutsch</option>103
</v-select>104
</div>105
<button106
class="h-[52px] px-4 mx-4 text-md bg-zinc-100 hover:bg-zinc-300 text-zinc-900 rounded-md outline-none mt-8"107
@click="register"108
>109
Sign up now110
</button>111
</div>112
<div v-if="method === 'login'" class="w-full flex flex-col gap-5 -mt-12">113
<v-button114
icon="arrow-left"115
title="Back"116
@click="method = null"117
class="self-start"118
>119
</v-button>120
<h3 class="text-white text-[24px] font-bold pb-4 px-4 sm:pt-0">Log In</h3>121
<div class="flex flex-col gap-1 w-full px-4">122
<label for="token" class="text-white text-lg">Insert account token</label>123
<input124
v-model="token"125
id="token"126
type="text"127
spellcheck="false"128
autocomplete="off"129
class="rounded-md w-full h-[52px] px-4 mt-2 text-md bg-zinc-900 text-white placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"130
>131
</div>132
<button133
class="h-[52px] px-4 mx-4 text-md bg-zinc-100 hover:bg-zinc-300 text-zinc-900 rounded-md outline-none mt-8"134
@click="login"135
>136
Sign In137
</button>138
</div>139
</div>140
</v-tab>141
`142
}