mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 04:24:00 +00:00
Account - active & invite user
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 15/03/2019
|
||||
* Time: 5:22 PM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserInvitationObject;
|
||||
use App\Models\UserInvitation;
|
||||
|
||||
class DeletesUserInvitation
|
||||
{
|
||||
/** @var UserInvitation */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* DeletesUserInvitation constructor.
|
||||
* @param UserInvitation $repository
|
||||
*/
|
||||
public function __construct(UserInvitation $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
public function execute(int $id ){
|
||||
|
||||
$userInvitation = $this->repository->findOrFail($id);
|
||||
|
||||
$userInvitation -> delete();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 14/03/2019
|
||||
* Time: 4:02 PM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Models\UserInvitation;
|
||||
use App\Http\Resources\UserInvitation as UserInvitationResources;
|
||||
|
||||
class ListsUserInvitation
|
||||
{
|
||||
/** @var UserInvitation */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsUserInvitation constructor.
|
||||
* @param UserInvitation $repository
|
||||
*/
|
||||
public function __construct(UserInvitation $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
public function execute(){
|
||||
|
||||
$userInvitation = $this->repository->where('is_complete', 0)->paginate(10);
|
||||
|
||||
return UserInvitationResources::collection($userInvitation);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 15/03/2019
|
||||
* Time: 5:18 PM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\ControllersLogic\Accounts;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\DeletesUserInvitation;
|
||||
|
||||
class DeleteUserInvitationLogic
|
||||
{
|
||||
/** @var DeletesUserInvitation */
|
||||
private $DeletesUserInvitation;
|
||||
|
||||
/**
|
||||
* DeleteUserInvitationLogic constructor.
|
||||
* @param DeletesUserInvitation $DeletesUserInvitation
|
||||
*/
|
||||
public function __construct(DeletesUserInvitation $DeletesUserInvitation)
|
||||
{
|
||||
$this->DeletesUserInvitation = $DeletesUserInvitation;
|
||||
}
|
||||
|
||||
public function execute(int $id){
|
||||
|
||||
return $this->DeletesUserInvitation->execute($id);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 14/03/2019
|
||||
* Time: 4:15 PM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\ControllersLogic\Accounts;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\ListsUserInvitation;
|
||||
|
||||
class ListUserInvitationLogic
|
||||
{
|
||||
/** @var ListsUserInvitation */
|
||||
private $ListsUserInvitation;
|
||||
|
||||
/**
|
||||
* ListUserInvitationLogic constructor.
|
||||
* @param ListsUserInvitation $ListsUserInvitation
|
||||
*/
|
||||
public function __construct(ListsUserInvitation $ListsUserInvitation)
|
||||
{
|
||||
$this->ListsUserInvitation = $ListsUserInvitation;
|
||||
}
|
||||
|
||||
public function execute(){
|
||||
return $this->ListsUserInvitation->execute();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 15/03/2019
|
||||
* Time: 5:16 PM
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
|
||||
use App\Classes\Modules\ControllersLogic\Accounts\DeleteUserInvitationLogic;
|
||||
|
||||
class DeleteInviteUserController
|
||||
{
|
||||
public function delete(int $id, DeleteUserInvitationLogic $logic){
|
||||
|
||||
return $logic->execute($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 14/03/2019
|
||||
* Time: 4:00 PM
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
|
||||
use App\Classes\Modules\ControllersLogic\Accounts\ListUserInvitationLogic;
|
||||
|
||||
class ListInviteUserController
|
||||
{
|
||||
public function list(ListUserInvitationLogic $logic){
|
||||
|
||||
return $logic->execute();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserInvitation extends JsonResource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'email' => $this->email,
|
||||
'created_at' =>Carbon::parse($this->created_at)->format('d/m/Y')
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\App\Models\UserInvitation::class, function (Faker $faker) {
|
||||
return [
|
||||
'email' => $faker->email,
|
||||
'hash' => $faker->randomNumber(),
|
||||
'role_id' => 1,
|
||||
'sender_id' => 1,
|
||||
'is_complete' => 0
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserInvitationsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
factory(App\Models\UserInvitation::class, 30)->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div class="row m-t-10 parentContainer">
|
||||
<div class="col">
|
||||
<div class="row no-margin">
|
||||
<div class="col bg-white">
|
||||
<div class="row align-items-center justify-content-center fs-11 p-t-10 p-b-10">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col bold"><span class="text-complete">{{this.account.email}}</span></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col muted">{{this.account.created_at}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto text-right">
|
||||
<div class="dropdown show">
|
||||
<button class="btn btn-secondary btn-xs b-rad-none p-r-0 muted" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span>Action</span><i class="fa fa-angle-down m-l-5 p-l-5 p-r-5 muted"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right no-padding pointer" aria-labelledby="dropdownMenuLink">
|
||||
<div class="dropdown-item btn-xs p-t-0 p-l-15 p-r-15 b-b b-grey requestModal" data-type="delete">
|
||||
<i class="fa fa-trash"></i> <span class="">Delete</span>
|
||||
</div>
|
||||
<div class="dropdown-item btn-xs p-b-0 p-l-15 p-r-15" @click="resendInvite()">
|
||||
<i class="fa fa-envelope"></i> <span class="">Resend</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<confirm-modal-component
|
||||
title="Delete Invitation"
|
||||
:message="'Are you sure you want to remove?'"
|
||||
type="delete"
|
||||
danger
|
||||
v-on:confirm="deleteInvite()"></confirm-modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: ['data'],
|
||||
data() {
|
||||
return {
|
||||
account: this.data
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteInvite(){
|
||||
this.isLoading = true;
|
||||
|
||||
fetch(route('api.account.invite.delete', {'id': this.account.id}), {
|
||||
method: 'delete'
|
||||
}).catch(error => console.log(error));
|
||||
|
||||
Event.$emit('updateInviteList');
|
||||
this.isLoading = false;
|
||||
},
|
||||
resendInvite(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -55,13 +55,12 @@
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
}).then((response) => {
|
||||
this.clearForm();
|
||||
}).catch(error => console.log(error));
|
||||
|
||||
//turn off loading animation
|
||||
this.clearForm();
|
||||
Event.$emit('updateInviteList');
|
||||
this.isLoading = false;
|
||||
|
||||
})
|
||||
},
|
||||
clearForm(){
|
||||
this.invite.email = ''
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div class="h-100">
|
||||
<div class="relative h-100" style="min-height: 200px;">
|
||||
<loading-component v-show="isLoading"></loading-component>
|
||||
<invite-account-component v-for="account in accounts" v-bind:key="account.id" :data="account"></invite-account-component>
|
||||
<pagination-component class="m-b-20 m-t-20" ref="pagination" v-on:changePage="fetchInvites($event)"></pagination-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
accounts: [],
|
||||
isLoading: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('updateInviteList', () => {
|
||||
this.fetchInvites();
|
||||
});
|
||||
},
|
||||
|
||||
created() {
|
||||
this.fetchInvites();
|
||||
},
|
||||
methods: {
|
||||
fetchInvites(page = 1){
|
||||
|
||||
//turn on loading animation
|
||||
this.isLoading = true;
|
||||
|
||||
fetch(route('api.account.list.invite') + '?page='+ page).then(response => response.json())
|
||||
.then(response => {
|
||||
|
||||
this.accounts = response.data;
|
||||
|
||||
this.$refs.pagination.makePagination(response.meta, response.links);
|
||||
|
||||
//turn off loading animation
|
||||
this.isLoading = false;
|
||||
|
||||
})
|
||||
.catch(error => console.log(error));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -26,6 +26,16 @@
|
||||
type: String,
|
||||
default: "stick-up"
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('closeModal', () => {
|
||||
this.closeModal();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
$(this.$el).find('.modal').modal('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -65,10 +65,9 @@
|
||||
<accounts-list-component></accounts-list-component>
|
||||
</div>
|
||||
<div class="tab-pane" id="invitesList">
|
||||
|
||||
<invite-account-list-component></invite-account-list-component>
|
||||
</div>
|
||||
<div class="tab-pane" id="blockedList">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user