A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 8e0273f6011a3f19cf278e5b0d4ce2d622ab14c1 (6039 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
$route('/', { reload: true });33
}34
catch(err) {35
console.error(err);36
}37
},38
async login() {39
try {40
localStorage.setItem('verbal-token', this.token);41
await http`get::/api/account`();42
$route('/', { reload: true });43
}44
catch(err) {45
localStorage.removeItem('verbal-token');46
console.error(err);47
}48
}49
},50
template: `51
<v-tab id="auth" :tab="state.tab">52
<div class="flex flex-col items-center justify-center h-screen min-h-screen">53
<div v-if="method === null">54
<h3 class="text-white text-[34px] font-bold pb-4 -mt-14 text-center">{{$lang('global.brand')}}</h3>55
<p class="text-md text-gray-400 text-center pb-12 px-4">{{$lang('global.slogan')}}</p>56
<div class="flex flex-col gap-5 w-full px-4">57
<button58
class="w-full h-[52px] px-4 text-md bg-zinc-100 hover:bg-zinc-300 text-zinc-900 rounded-md outline-none"59
@click="method = 'register'"60
>61
{{$lang('global.register')}}62
</button>63
<button64
class="w-full h-[52px] px-4 text-md bg-zinc-900 hover:bg-zinc-800 text-zinc-100 rounded-md outline-none"65
@click="method = 'login'"66
>67
{{$lang('global.login')}}68
</button>69
</div>70
</div>71
<div v-if="method === 'register'" class="w-full flex flex-col gap-5 -mt-12">72
<v-button73
icon="arrow-left"74
title="Back"75
@click="method = null"76
class="self-start"77
>78
</v-button>79
<h3 class="text-white text-[24px] font-bold pb-4 px-4 sm:pt-0">{{$lang('global.register')}}</h3>80
<div class="flex flex-col gap-1 w-full px-4">81
<label for="username" class="text-white text-lg">Choose your username</label>82
<input83
v-model="name"84
id="username"85
type="text"86
maxlength="20"87
spellcheck="false"88
autocomplete="off"89
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"90
>91
</div>92
<div class="flex flex-col gap-1 w-full px-4">93
<label for="language" class="text-white text-lg">Select language</label>94
<v-select95
id="language"96
v-model="language"97
class="mt-2"98
>99
<option value="en">English</option>100
<option value="de">Deutsch</option>101
</v-select>102
</div>103
<button104
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"105
@click="register"106
>107
{{$lang('global.register.now')}}108
</button>109
</div>110
<div v-if="method === 'login'" class="w-full flex flex-col gap-5 -mt-12">111
<v-button112
icon="arrow-left"113
title="Back"114
@click="method = null"115
class="self-start"116
>117
</v-button>118
<h3 class="text-white text-[24px] font-bold pb-4 px-4 sm:pt-0">{{$lang('global.login')}}</h3>119
<div class="flex flex-col gap-1 w-full px-4">120
<label for="token" class="text-white text-lg">Insert account token</label>121
<input122
v-model="token"123
id="token"124
type="text"125
spellcheck="false"126
autocomplete="off"127
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"128
>129
</div>130
<button131
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"132
@click="login"133
>134
{{$lang('global.login.now')}}135
</button>136
</div>137
</div>138
</v-tab>139
`140
}