Compare commits

...

2 Commits

Author SHA1 Message Date
760b1b32a2 added baseurl_selfservice config
close #22
2021-03-26 20:10:26 +01:00
7b0bc22a71 [tmp] vue i18n error 2021-03-26 18:36:52 +01:00
7 changed files with 91 additions and 86 deletions

View File

@ -3,6 +3,8 @@ const config = {
documentserver_key: '',
// required
baseurl: '',
// optional, will fallback to /selfservice
baseurl_selfservice: '/selfservice',
// optional, will fallback to /imprint
url_imprint: '',
// optional, will fallback to /privacy

View File

@ -3,5 +3,5 @@
</template>
<script setup>
//
config.baseurl_selfservices = (config.baseurl_selfservices || "/selfservice");
</script>

View File

@ -9,7 +9,7 @@
<p
v-if="state.org_name !== ''"
class="mx-auto leading-relaxed text-base text-center"
>Organization: {{ state.org_name }}</p>
>{{ $t('organization') }}: {{ state.org_name }}</p>
<p v-else class="mx-auto leading-relaxed text-base text-center">Bürgerlauf</p>
<div class="mt-4">
<label for="first_name" class="block font-medium">
@ -247,6 +247,8 @@ import isEmail from 'validator/es/lib/isEmail';
import isMobilePhone from 'validator/es/lib/isMobilePhone';
import isPostalCode from 'validator/es/lib/isPostalCode';
import { useToast } from "vue-toastification";
import { router } from '../router';
import { i18n } from '../language';
const props = defineProps({
token: String
@ -305,9 +307,7 @@ function login() {
axios.post(url, postdata)
.then(({ data }) => {
const token = btoa(data.token);
location.replace("../profile/" + token)
//
toast.success("You have been registered!");
router.push(`${config.baseurl_selfservices}/profile/${token}`);
})
.catch((error) => {
console.log(error);

14
src/language.js Normal file
View File

@ -0,0 +1,14 @@
import * as keys_en from './locales/en.json';
import * as keys_de from './locales/de.json';
import { createI18n } from 'vue-i18n';
const messages = {
en: keys_en,
de: keys_de
};
const browserlocale = ((navigator.languages && navigator.languages[0]) || '').substr(0, 2);
export const i18n = createI18n({
locale: browserlocale,
fallbackLocale: 'en',
messages
});

View File

@ -37,5 +37,7 @@
"this_is_not_a_valid_international_phone_number": "This is not a valid international phone number",
"tos": "Terms of Service",
"view_my_data": "View my data",
"vorname": "Firstname"
"vorname": "Firstname",
"organization": "Organization",
"you_have_been_registered": "You have been registered!"
}

View File

@ -1,49 +1,10 @@
import { createApp } from 'vue';
import { createWebHistory, createRouter } from 'vue-router';
import App from './App.vue';
import { createI18n } from 'vue-i18n';
import Toast from 'vue-toastification';
import 'windi.css';
import 'toastify-js/src/toastify.css';
import 'vue-toastification/dist/index.css';
import * as keys_en from './locales/en.json';
import * as keys_de from './locales/de.json';
import { router } from './router';
import { i18n } from './language';
const messages = {
en: keys_en,
de: keys_de
};
const browserlocale = ((navigator.languages && navigator.languages[0]) || '').substr(0, 2);
const i18n = createI18n({
locale: browserlocale,
fallbackLocale: 'en',
messages
});
// ---------------
const EnvError = import('./components/EnvError.vue');
const Home = import('./components/Home.vue');
const Imprint = import('./components/Imprint.vue');
const Privacy = import('./components/Privacy.vue');
const Register = () => import('./components/Register.vue');
const Profile = () => import('./components/Profile.vue');
//
let routes = [ { path: '/:pathMatch(.*)*', component: EnvError } ];
if (typeof config !== 'undefined') {
if (config.baseurl && config.documentserver_key) {
routes = [
{ path: '/', component: Home },
{ path: '/imprint', component: Imprint },
{ path: '/privacy', component: Privacy },
{ path: '/register', component: Register },
{ path: '/register/:token', component: Register, props: true },
{ path: '/profile/:token', component: Profile, props: true }
];
}
}
const router = createRouter({
history: createWebHistory(),
routes
});
// ---------------
createApp(App).use(Toast).use(i18n).use(router).mount('#app');

26
src/router.js Normal file
View File

@ -0,0 +1,26 @@
import { createWebHistory, createRouter } from 'vue-router';
// ------------
const EnvError = import('./components/EnvError.vue');
const Home = import('./components/Home.vue');
const Imprint = import('./components/Imprint.vue');
const Privacy = import('./components/Privacy.vue');
const Register = () => import('./components/Register.vue');
const Profile = () => import('./components/Profile.vue');
//
let routes = [ { path: '/:pathMatch(.*)*', component: EnvError } ];
if (typeof config !== 'undefined') {
if (config.baseurl && config.documentserver_key) {
routes = [
{ path: '/', component: Home },
{ path: '/imprint', component: Imprint },
{ path: '/privacy', component: Privacy },
{ path: '/register', component: Register },
{ path: '/register/:token', component: Register, props: true },
{ path: '/profile/:token', component: Profile, props: true }
];
}
}
export const router = createRouter({
history: createWebHistory(),
routes
});