Skip to content

Commit

Permalink
fix #127, fix #138, fix #175, fix #173 (#186)
Browse files Browse the repository at this point in the history
* fix #147, fix #148, fix #150, fix #151, fix #154,
fix #159

* fix #127, fix #138, fix #175, fix #173
  • Loading branch information
FlorinZarafu authored Jul 27, 2023
1 parent cead31e commit b6265a7
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 149 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ public function store(RegistrationRequest $request): RedirectResponse
'name' => $user['name'],
'email' => $user['email'],
'password' => Hash::make($user['password']),
'role' => $data['type']
]);
event(new Registered($user));

if ($data['type'] == 'ong') {
$ong = $data['ong'];
if ($data['type'] == 'ngo-admin') {
$ong = $data['ngo-admin'];
$organization = Organization::create($ong);
$organization->activityDomains()->attach($ong['activity_domains_ids']);
$organization->counties()->attach($ong['counties_ids']);
Expand Down
35 changes: 26 additions & 9 deletions resources/js/Components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,20 @@
<MenuItems class="absolute right-0 z-10 w-48 py-1 mt-2 origin-top-right bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
<!-- Administrate Link -->
<NavLink
v-if="$page.props.auth.user && 'donor' === $page.props.auth.user.role"
class="w-full px-3 py-2"
:href="'donor' === $page.props.auth.user.role ? route('donor.index') : route('dashboard')"
:active="'donor' === $page.props.auth.user.role ? route().current('donor.index') : route().current('dashboard')"
:href="route('donor.index')"
:active="route().current('donor.index')"
>
{{ 'donor' === $page.props.auth.user.role ? $t('dashbord') : $t('administrate_link') }}
{{ $t('dashbord') }}
</NavLink>
<NavLink
v-if="$page.props.auth.user && 'ngo-admin' === $page.props.auth.user.role"
class="w-full px-3 py-2"
:href="route('dashboard')"
:active="route().current('dashboard')"
>
{{ $t('administrate_link') }}
</NavLink>

<NavLink
Expand Down Expand Up @@ -202,14 +211,22 @@
</div>

<div class="mt-3 space-y-1">
<!-- Administrate Link -->
<NavLink
v-if="$page.props.auth.user"
<!-- Administrate Link -->
<NavLink
v-if="$page.props.auth.user && 'donor' === $page.props.auth.user.role"
class="w-full px-3 py-2"
:href="route('donor.index')"
:active="route().current('donor.index')"
>
{{ $t('dashbord') }}
</NavLink>
<NavLink
v-if="$page.props.auth.user && 'ngo-admin' === $page.props.auth.user.role"
class="w-full px-3 py-2"
:href="'donor' === $page.props.auth.user.role ? route('donor.index') : route('dashboard')"
:active="'donor' === $page.props.auth.user.role ? route().current('donor.index') : route().current('dashboard')"
:href="route('dashboard')"
:active="route().current('dashboard')"
>
{{ 'donor' === $page.props.auth.user.role ? $t('dashbord') : $t('administrate_link') }}
{{ $t('administrate_link') }}
</NavLink>

<NavLink
Expand Down
8 changes: 6 additions & 2 deletions resources/js/Components/cards/OngCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
<div class="flex flex-col flex-1 p-6">
<img class="flex-shrink-0 w-32 h-32 mx-auto rounded-full" :src="data.cover_image ? data.cover_image: '/images/ong.png'" alt="" />

<h3 class="mt-4 text-2xl font-bold text-gray-700 line-clamp-2">{{ data.name }}</h3>
<Link
:href="route('organization', data.id)"
class="mt-4 text-2xl font-bold text-gray-700 line-clamp-2"
>
{{ data.name }}
</Link>

<div class="flex flex-wrap items-center gap-5 mt-1 mb-6 text-base font-medium text-gray-800">
<div v-if="0 < data.activity_domains?.length" class="flex items-center gap-1">
Expand Down Expand Up @@ -32,7 +37,6 @@
/** Import components. */
import SvgLoader from '@/Components/SvgLoader.vue';
import PrimaryButton from '@/Components/buttons/PrimaryButton.vue';
/** Component props. */
defineProps({
Expand Down
1 change: 0 additions & 1 deletion resources/js/Components/form/SelectMultiple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
{{ option.name ? option.name : option }}
<XCircleIcon class="w-4 h-4 ml-2 text-white" aria-hidden="true"/>
</div>

<!-- Error -->
<p v-show="error" class="mt-2 text-sm text-red-600">{{ error }}</p>
</Combobox>
Expand Down
23 changes: 14 additions & 9 deletions resources/js/Components/pagination/Pagination.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<nav class="flex items-center justify-between border-t border-gray-200 px-4 sm:px-0">
<nav class="flex items-center justify-between px-4 border-t border-gray-200 sm:px-0">

<!-- Next -->
<div class="-mt-px flex w-0 flex-1">
<div class="flex flex-1 w-0 -mt-px">
<Link
v-if="prev"
:href="prev"
class="inline-flex items-center border-t-2 border-transparent pr-1 pt-4 text-sm font-medium text-gray-500 hover:border-gray-300 hover:text-gray-700"
class="inline-flex items-center pt-4 pr-1 text-sm font-medium text-gray-500 border-t-2 border-transparent hover:border-gray-300 hover:text-gray-700"
>
<ArrowLongLeftIcon class="mr-3 h-5 w-5 text-gray-400" aria-hidden="true" />
<ArrowLongLeftIcon class="w-5 h-5 mr-3 text-gray-400" aria-hidden="true" />
{{ $t('prev') }}
</Link>
</div>
Expand All @@ -28,14 +28,14 @@
</div>

<!-- Prev -->
<div class="-mt-px flex w-0 flex-1 justify-end">
<div class="flex justify-end flex-1 w-0 -mt-px">
<Link
v-if="next"
:href="next"
class="inline-flex items-center border-t-2 border-transparent pl-1 pt-4 text-sm font-medium text-gray-500 hover:border-gray-300 hover:text-gray-700"
class="inline-flex items-center pt-4 pl-1 text-sm font-medium text-gray-500 border-t-2 border-transparent hover:border-gray-300 hover:text-gray-700"
>
{{ $t('next') }}
<ArrowLongRightIcon class="ml-3 h-5 w-5 text-gray-400" aria-hidden="true" />
<ArrowLongRightIcon class="w-5 h-5 ml-3 text-gray-400" aria-hidden="true" />
</Link>
</div>
</nav>
Expand All @@ -62,8 +62,13 @@
const paginationLinks = computed(() => {
const links = props.links;
links.shift();
links.pop();
if('&laquo; Previous' === links[0].label) {
links.shift();
}
if('Next &raquo;' == links[links.length - 1].label) {
links.pop();
}
return links;
})
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/registration/Step1.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
label: 'Creează cont organizație',
value: 'ong',
value: 'ngo-admin',
description: 'Vrei ca ONG-ul din care faci parte să apară pe Bursa Binelui? Înscrie organizația acum.'
},
]);
Expand Down
8 changes: 4 additions & 4 deletions resources/js/Components/registration/Step2.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<div class="space-y-6">

<h1 v-if="'ong' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('account_details') }}</h1>
<h1 v-if="'ngo-admin' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('account_details') }}</h1>

<!-- Name -->
<Input
:label="'ong' == form.type ? $t('name_last_name_ong') : $t('name_last_name')"
:label="'ngo-admin' == form.type ? $t('name_last_name_ong') : $t('name_last_name')"
id="name"
type="text"
v-model="form.user.name"
Expand Down Expand Up @@ -70,7 +70,7 @@
<span class="text-sm text-gray-700">{{ $t('register_subscribe') }}</span>
</label>

<div v-if="'ong' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<div v-if="'ngo-admin' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<PrimaryButton
background="white"
hover="white"
Expand Down Expand Up @@ -99,7 +99,7 @@
color="white"
@click="$emit('next', $event.target)"
>
{{ 'Step1' == current.__name ? $t('continue') : $t('register_link') }}
{{ $t('register_link') }}
</PrimaryButton>

<SecondaryButton
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Components/registration/Step3.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="space-y-6">

<h1 v-if="'ong' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('ong_profile') }}</h1>
<h1 v-if="'ngo-admin' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('ong_profile') }}</h1>

<!-- Ong Name -->
<Input
Expand Down Expand Up @@ -73,7 +73,7 @@
<p class="block mt-1 text-xs font-medium leading-6 text-gray-500">{{ $t('file_description') }}</p>
</div>

<div v-if="'ong' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<div v-if="'ngo-admin' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<PrimaryButton
background="white"
hover="white"
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Components/registration/Step4.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="space-y-6">

<h1 v-if="'ong' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('contact_ong') }}</h1>
<h1 v-if="'ngo-admin' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('contact_ong') }}</h1>

<!-- County -->
<div class="w-full">
Expand Down Expand Up @@ -81,7 +81,7 @@
:error="form.errors['ong.webiste']"
/>

<div v-if="'ong' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<div v-if="'ngo-admin' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<PrimaryButton
background="white"
hover="white"
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Components/registration/Step5.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="space-y-6">

<h1 v-if="'ong' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('register_volunteer') }}</h1>
<h1 v-if="'ngo-admin' == form.type" class="text-2xl font-bold text-cyan-900">{{ $t('register_volunteer') }}</h1>

<p class="text-sm text-gray-700">{{ $t('register_volunteer') }}</p>

Expand All @@ -26,7 +26,7 @@
<p class="text-xs font-normal text-gray-500">{{ $t('why_volunteer_info') }}</p>
</Textarea>

<div v-if="'ong' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<div v-if="'ngo-admin' == form.type" class="flex items-center justify-between mt-6 gap-x-4">
<PrimaryButton
background="white"
hover="white"
Expand Down
31 changes: 21 additions & 10 deletions resources/js/Pages/Auth/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@

<!-- Auth template. -->
<Auth :content="content">

<!-- Steps -->
<div class="mt-6">
<component :is="steps[current]" :current="steps[current]" :form="form" :social="social"
:activity_domains="activity_domains" :counties="counties" @prev="prev" @next="next" @google="google"
@success="success" />
<component
:is="steps[current]"
:current="steps[current]"
:form="form"
:social="social"
:activity_domains="activity_domains"
:counties="counties"
@prev="prev"
@next="next"
@google="google"
@success="success"
/>
</div>
</Auth>
</PageLayout>
Expand All @@ -22,7 +30,7 @@
import { ref, computed } from 'vue';
/** Import form inertia. */
import { Head, useForm, usePage } from '@inertiajs/vue3';
import { Head, useForm } from '@inertiajs/vue3';
/** Import components. */
import PageLayout from '@/Layouts/PageLayout.vue';
Expand Down Expand Up @@ -74,7 +82,6 @@ const props = defineProps({
type: Array,
default: () => []
},
user: Object,
flash: Object
});
Expand All @@ -89,7 +96,7 @@ const steps = computed(() => {
let components = [Step1, Step2];
/** Check if registration is of type oragnization */
if ('ong' === form.type) {
if ('ngo-admin' === form.type) {
components = [...components, Step3, Step4, Step5];
}
Expand Down Expand Up @@ -122,7 +129,7 @@ const prev = (() => (0 < current.value) && current.value--);
const next = () => {
if ('donor' === form.type && current.value === 1) {
submit()
} else if ('ong' === form.type && current.value === 4) {
} else if ('ngo-admin' === form.type && current.value === 4) {
submit()
} else if ('' !== form.type) {
current.value++
Expand All @@ -140,7 +147,9 @@ const submit = () => {
delete form.ong;
}
if(form.type = 'ong') {
console.log(form.type)
if(form.type === 'ngo-admin') {
form.ong.activity_domains_ids = form.ong.activity_domains_ids.map(domain => domain.id)
form.ong.counties_ids = form.ong.counties_ids.map(county => county.id)
}
Expand All @@ -159,7 +168,7 @@ const submit = () => {
}
/** Repopulate array as objects. */
if(form.type = 'ong') {
if(form.type === 'ngo-admin') {
if (0 < form.ong.activity_domains_ids.length) {
form.ong.activity_domains_ids = props.activity_domains.filter(domain => form.ong.activity_domains_ids.includes(domain.id));
}
Expand All @@ -170,7 +179,9 @@ const submit = () => {
}
},
onSuccess: (data) => {
console.log(data)
current.value = steps.value.length - 1
console.log(current.value)
if (data?.props?.flash?.success_message?.usrid) {
usrid.value = data.props.flash.success_message.usrid
}
Expand Down
Loading

0 comments on commit b6265a7

Please sign in to comment.