A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 25c4319f9bbcb34ec86ef7c1b739e397c3c79a1f (5899 bytes)[doc][blame][raw]
1
import {$lang, 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
async register() {24
try {25
localStorage.removeItem('verbal-token');26
const device = await http`post::/api/account`({27
name: this.name,28
language: this.language29
});30
localStorage.setItem('verbal-token', device.uid);31
this.state.app.init();32
}33
catch(err) {34
console.error(err);35
}36
},37
async login() {38
try {39
localStorage.setItem('verbal-token', this.token);40
await http`get::/api/account`();41
this.state.app.init();42
}43
catch(err) {44
localStorage.removeItem('verbal-token');45
console.error(err);46
}47
}48
},49
template: `50
<v-tab id="account" :tab="state.tab">51
<div class="flex flex-col items-center justify-center h-screen min-h-screen">52
<div v-if="method === null">53
<h3 class="text-white text-[34px] font-bold pb-4 -mt-14 text-center">{{$lang('global.brand')}}</h3>54
<p class="text-md text-gray-400 text-center pb-12 px-4">{{$lang('global.slogan')}}</p>55
<div class="flex flex-col gap-5 w-full px-4">56
<button57
class="w-full h-[52px] px-4 text-md bg-zinc-100 hover:bg-zinc-300 text-zinc-900 rounded-md outline-none"58
@click="method = 'register'"59
>60
Create an account61
</button>62
<button63
class="w-full h-[52px] px-4 text-md bg-zinc-900 hover:bg-zinc-800 text-zinc-100 rounded-md outline-none"64
@click="method = 'login'"65
>66
Log In67
</button>68
</div>69
</div>70
<div v-if="method === 'register'" class="w-full flex flex-col gap-5 -mt-12">71
<v-button72
icon="arrow-left"73
title="Back"74
@click="method = null"75
class="self-start"76
>77
</v-button>78
<h3 class="text-white text-[24px] font-bold pb-4 px-4 sm:pt-0">Create an account</h3>79
<div class="flex flex-col gap-1 w-full px-4">80
<label for="username" class="text-white text-lg">Choose your username</label>81
<input82
v-model="name"83
id="username"84
type="text"85
maxlength="20"86
spellcheck="false"87
autocomplete="off"88
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"89
>90
</div>91
<div class="flex flex-col gap-1 w-full px-4">92
<label for="language" class="text-white text-lg">Select language</label>93
<v-select94
id="language"95
v-model="language"96
class="mt-2"97
>98
<option value="en">English</option>99
<option value="de">Deutsch</option>100
</v-select>101
</div>102
<button103
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"104
@click="register"105
>106
Sign up now107
</button>108
</div>109
<div v-if="method === 'login'" class="w-full flex flex-col gap-5 -mt-12">110
<v-button111
icon="arrow-left"112
title="Back"113
@click="method = null"114
class="self-start"115
>116
</v-button>117
<h3 class="text-white text-[24px] font-bold pb-4 px-4 sm:pt-0">Log In</h3>118
<div class="flex flex-col gap-1 w-full px-4">119
<label for="token" class="text-white text-lg">Insert account token</label>120
<input121
v-model="token"122
id="token"123
type="text"124
spellcheck="false"125
autocomplete="off"126
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"127
>128
</div>129
<button130
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"131
@click="login"132
>133
Sign In134
</button>135
</div>136
</div>137
</v-tab>138
`139
}