Skip to content

Commit

Permalink
Merge pull request #1296 from seatplus/feature/onboarding
Browse files Browse the repository at this point in the history
Feature/onboarding
  • Loading branch information
herpaderpaldent authored Oct 16, 2022
2 parents 46f6075 + 0e0a231 commit 6876480
Show file tree
Hide file tree
Showing 14 changed files with 888 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/web.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
return [
'EVE_CLIENT_ID' => env('EVE_CLIENT_ID'),
'EVE_CLIENT_SECRET' => env('EVE_CLIENT_SECRET'),
'ONBOARDING' => env('ONBOARDING', false),
];
43 changes: 43 additions & 0 deletions database/migrations/2022_10_19_221652_create_onboardings_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* MIT License
*
* Copyright (c) 2019, 2020, 2021 Felix Huber
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{

public function up()
{
Schema::create('onboardings', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
$table->timestamps();
});
}

};
13 changes: 13 additions & 0 deletions resources/js/Functions/useResolveId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from "axios";
import {ref} from "vue";

export function useResolveId(id) {

let result = ref()

axios.get(route('resolve.id', id))
.then((response) => result.value = response.data)
.catch(error => console.log(error))

return result
}
182 changes: 182 additions & 0 deletions resources/js/Pages/Onboarding/AddCharacters.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<template>
<div class="bg-gray-100">
<div class="mx-auto max-w-7xl px-4 sm:py-24 sm:px-6 lg:px-8">
<div class="relative bg-gray-50 shadow-xl">
<h2 class="sr-only">
Add Characters
</h2>

<div class="grid grid-cols-1 lg:grid-cols-3">
<!-- Contact information -->
<div class="relative overflow-hidden bg-indigo-700 py-10 px-6 sm:px-10 xl:p-12">
<div
class="pointer-events-none absolute inset-0 sm:hidden"
aria-hidden="true"
>
<svg
class="absolute inset-0 h-full w-full"
width="343"
height="388"
viewBox="0 0 343 388"
fill="none"
preserveAspectRatio="xMidYMid slice"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M-99 461.107L608.107-246l707.103 707.107-707.103 707.103L-99 461.107z"
fill="url(#linear1)"
fill-opacity=".1"
/>
<defs>
<linearGradient
id="linear1"
x1="254.553"
y1="107.554"
x2="961.66"
y2="814.66"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#fff" />
<stop
offset="1"
stop-color="#fff"
stop-opacity="0"
/>
</linearGradient>
</defs>
</svg>
</div>
<div
class="pointer-events-none absolute top-0 right-0 bottom-0 hidden w-1/2 sm:block lg:hidden"
aria-hidden="true"
>
<svg
class="absolute inset-0 h-full w-full"
width="359"
height="339"
viewBox="0 0 359 339"
fill="none"
preserveAspectRatio="xMidYMid slice"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M-161 382.107L546.107-325l707.103 707.107-707.103 707.103L-161 382.107z"
fill="url(#linear2)"
fill-opacity=".1"
/>
<defs>
<linearGradient
id="linear2"
x1="192.553"
y1="28.553"
x2="899.66"
y2="735.66"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#fff" />
<stop
offset="1"
stop-color="#fff"
stop-opacity="0"
/>
</linearGradient>
</defs>
</svg>
</div>
<div
class="pointer-events-none absolute top-0 right-0 bottom-0 hidden w-1/2 lg:block"
aria-hidden="true"
>
<svg
class="absolute inset-0 h-full w-full"
width="160"
height="678"
viewBox="0 0 160 678"
fill="none"
preserveAspectRatio="xMidYMid slice"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M-161 679.107L546.107-28l707.103 707.107-707.103 707.103L-161 679.107z"
fill="url(#linear3)"
fill-opacity=".1"
/>
<defs>
<linearGradient
id="linear3"
x1="192.553"
y1="325.553"
x2="899.66"
y2="1032.66"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#fff" />
<stop
offset="1"
stop-color="#fff"
stop-opacity="0"
/>
</linearGradient>
</defs>
</svg>
</div>
<h3 class="text-lg font-medium text-white">
Add Characters
</h3>
<p class="mt-6 max-w-3xl text-base text-indigo-50">
Please add all characters you want to track. You can add more later.
</p>
</div>

<!-- Contact form -->
<div class="flex flex-col justify-between py-10 px-6 sm:px-10 lg:col-span-2 xl:p-12">
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
<a
type="button"
:href="route('auth.eve')"
class="flex p-2 lg:col-span-2 border-2 border-dashed border-gray-300 hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 rounded-lg"
>
<div class="mb-4 shrink-0 sm:mb-0 mr-4 self-center">
<div>
<UserPlusIcon
class="h-10 w-10 rounded-full text-gray-900"
aria-hidden="true"
/>
</div>
</div>
<div class="flex flex-col justify-center">
<h3 class="text-lg leading-6 font-medium text-gray-900">
Add another character
</h3>
</div>
</a>
<EntityByIdBlock
v-for="character in characters"
:id="character.character_id"
:key="character.id"
:entity="character"
/>
</div>

<div class="sm:flex sm:justify-end">
<slot />
</div>
</div>
</div>
</div>
</div>
</div>
</template>

<script setup>
import EntityByIdBlock from "@/Shared/Layout/Eve/EntityByIdBlock.vue";
import { UserPlusIcon } from "@heroicons/vue/24/outline";
const props = defineProps({
characters: {
type: Array,
required: true,
},
});
</script>
132 changes: 132 additions & 0 deletions resources/js/Pages/Onboarding/Index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<template>
<div class="absolute min-h-full min-w-full bg-gray-100 px-4 py-16 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8">
<main class="mx-auto flex w-full max-w-7xl flex-grow flex-col justify-center px-4 sm:px-6 lg:px-8">
<div class="flex flex-shrink-0 justify-center">
<a
href="/"
class="inline-flex"
>
<span class="sr-only">Seat Plus</span>
<img
class="h-12 w-auto"
src="/img/seat_plus_logo.svg"
alt="Seat Plus"
>
</a>
</div>
<div>
<Introduction
v-if="step === 1"
:main-character-id="mainCharacterId"
>
<Link
class="block w-full rounded-md border border-transparent bg-white py-3 px-5 text-center text-base font-medium text-indigo-700 shadow-md hover:bg-gray-50 sm:inline-block sm:w-auto"
:href="nextUrl"
>
Next
</Link>
</Introduction>
<OnboardingEnlistment
v-if="step === 2"
:main-character-id="mainCharacterId"
:enlistments="user_enlistments"
>
<Link
as="button"
:href="nextUrl"
class="mt-2 inline-flex w-full items-center justify-center rounded-md border border-transparent bg-indigo-600 px-6 py-3 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto"
>
Next
</Link>
</OnboardingEnlistment>
<AddCharacters
v-if="step === 3"
:characters="characters"
>
<Link
:key="character_enlistments.length"
as="button"
:method="character_enlistments.length > 0 ? 'get' : 'post'"
:href="nextUrl"
class="mt-2 inline-flex w-full items-center justify-center rounded-md border border-transparent bg-indigo-600 px-6 py-3 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto"
>
{{ character_enlistments.length > 0 ? 'Next' : 'Finish' }}
</Link>
</AddCharacters>
<OnboardingEnlistment
v-if="step === 4"
:main-character-id="mainCharacterId"
:enlistments="character_enlistments"
>
<Link
as="button"
:href="nextUrl"
method="post"
class="mt-2 inline-flex w-full items-center justify-center rounded-md border border-transparent bg-indigo-600 px-6 py-3 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto"
>
Finish
</Link>
</OnboardingEnlistment>
</div>
</main>
</div>
</template>


<script>
export default {
layout: null,
}
</script>

<script setup>
import { computed } from "vue";
import { Link } from "@inertiajs/inertia-vue3";
import OnboardingEnlistment from "@/Pages/Onboarding/OnboardingEnlistment.vue";
import Introduction from "@/Pages/Onboarding/Introduction.vue";
import AddCharacters from "@/Pages/Onboarding/AddCharacters.vue";
const props = defineProps({
enlistments: {
required: true,
type: Array
},
characters: {
required: true,
type: Array
},
mainCharacterId: {
required: true,
type: Number
},
step: {
required: true,
type: Number
}
})
const user_enlistments = computed(() => {
return props.enlistments.filter(enlistment => enlistment.type === 'user')
})
const character_enlistments = computed(() => {
return props.enlistments.filter(enlistment => enlistment.type === 'character')
})
const nextUrl = computed(() => {
let route_name = route().current()
if(props.step === 1) {
return route(route_name, {step: user_enlistments.value.length > 0 ? 2 : 3})
}
if(props.step > 1) {
return route(route_name, {step: props.step + 1})
}
})
</script>

Loading

0 comments on commit 6876480

Please sign in to comment.