initial commit
This commit is contained in:
385
resources/js/@fake-db/apps/chat.js
Normal file
385
resources/js/@fake-db/apps/chat.js
Normal file
@@ -0,0 +1,385 @@
|
||||
import mock from '@/@fake-db/mock'
|
||||
import { genId } from '@/@fake-db/utils'
|
||||
|
||||
// Images
|
||||
import avatar1 from '@images/avatars/avatar-1.png'
|
||||
import avatar2 from '@images/avatars/avatar-2.png'
|
||||
import avatar3 from '@images/avatars/avatar-3.png'
|
||||
import avatar4 from '@images/avatars/avatar-4.png'
|
||||
import avatar5 from '@images/avatars/avatar-5.png'
|
||||
import avatar6 from '@images/avatars/avatar-6.png'
|
||||
import avatar8 from '@images/avatars/avatar-8.png'
|
||||
|
||||
const previousDay = new Date(new Date().getTime() - 24 * 60 * 60 * 1000)
|
||||
const dayBeforePreviousDay = new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 2)
|
||||
|
||||
const database = {
|
||||
profileUser: {
|
||||
id: 11,
|
||||
avatar: avatar1,
|
||||
fullName: 'John Doe',
|
||||
role: 'admin',
|
||||
about: 'Dessert chocolate cake lemon drops jujubes. Biscuit cupcake ice cream bear claw brownie marshmallow.',
|
||||
status: 'online',
|
||||
settings: {
|
||||
isTwoStepAuthVerificationEnabled: true,
|
||||
isNotificationsOn: false,
|
||||
},
|
||||
},
|
||||
contacts: [
|
||||
{
|
||||
id: 1,
|
||||
fullName: 'Gavin Griffith',
|
||||
role: 'Frontend Developer',
|
||||
about: 'Cake pie jelly jelly beans. Marzipan lemon drops halvah cake. Pudding cookie lemon drops icing',
|
||||
avatar: avatar5,
|
||||
status: 'offline',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
fullName: 'Harriet McBride',
|
||||
role: 'UI/UX Designer',
|
||||
about: 'Toffee caramels jelly-o tart gummi bears cake I love ice cream lollipop. Sweet liquorice croissant candy danish dessert icing. Cake macaroon gingerbread toffee sweet.',
|
||||
avatar: avatar2,
|
||||
status: 'busy',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
fullName: 'Danny Conner',
|
||||
role: 'Town planner',
|
||||
about: 'Soufflé soufflé caramels sweet roll. Jelly lollipop sesame snaps bear claw jelly beans sugar plum sugar plum.',
|
||||
avatar: '',
|
||||
status: 'busy',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
fullName: 'Janie West',
|
||||
role: 'Data scientist',
|
||||
about: 'Chupa chups candy canes chocolate bar marshmallow liquorice muffin. Lemon drops oat cake tart liquorice tart cookie. Jelly-o cookie tootsie roll halvah.',
|
||||
avatar: '',
|
||||
status: 'online',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
fullName: 'Bryan Murray',
|
||||
role: 'Dietitian',
|
||||
about: 'Cake pie jelly jelly beans. Marzipan lemon drops halvah cake. Pudding cookie lemon drops icing',
|
||||
avatar: avatar5,
|
||||
status: 'busy',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
fullName: 'Albert Underwood',
|
||||
role: 'Marketing executive',
|
||||
about: 'Toffee caramels jelly-o tart gummi bears cake I love ice cream lollipop. Sweet liquorice croissant candy danish dessert icing. Cake macaroon gingerbread toffee sweet.',
|
||||
avatar: avatar6,
|
||||
status: 'online',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
fullName: 'Adele Ross',
|
||||
role: 'Special educational needs teacher',
|
||||
about: 'Biscuit powder oat cake donut brownie ice cream I love soufflé. I love tootsie roll I love powder tootsie roll.',
|
||||
avatar: '',
|
||||
status: 'online',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
fullName: 'Mark Berry',
|
||||
role: 'Advertising copywriter',
|
||||
about: 'Bear claw ice cream lollipop gingerbread carrot cake. Brownie gummi bears chocolate muffin croissant jelly I love marzipan wafer.',
|
||||
avatar: avatar3,
|
||||
status: 'away',
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
fullName: 'Joseph Evans',
|
||||
role: 'Designer, television/film set',
|
||||
about: 'Gummies gummi bears I love candy icing apple pie I love marzipan bear claw. I love tart biscuit I love candy canes pudding chupa chups liquorice croissant.',
|
||||
avatar: avatar8,
|
||||
status: 'offline',
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
fullName: 'Blake Carter',
|
||||
role: 'Building surveyor',
|
||||
about: 'Cake pie jelly jelly beans. Marzipan lemon drops halvah cake. Pudding cookie lemon drops icing',
|
||||
avatar: avatar4,
|
||||
status: 'away',
|
||||
},
|
||||
],
|
||||
chats: [
|
||||
{
|
||||
id: 1,
|
||||
userId: 2,
|
||||
unseenMsgs: 0,
|
||||
messages: [
|
||||
{
|
||||
message: 'Hi',
|
||||
time: 'Mon Dec 10 2018 07:45:00 GMT+0000 (GMT)',
|
||||
senderId: 11,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'Hello. How can I help You?',
|
||||
time: 'Mon Dec 11 2018 07:45:15 GMT+0000 (GMT)',
|
||||
senderId: 2,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'Can I get details of my last transaction I made last month? 🤔',
|
||||
time: 'Mon Dec 11 2018 07:46:10 GMT+0000 (GMT)',
|
||||
senderId: 11,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'We need to check if we can provide you such information.',
|
||||
time: 'Mon Dec 11 2018 07:45:15 GMT+0000 (GMT)',
|
||||
senderId: 2,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'I will inform you as I get update on this.',
|
||||
time: 'Mon Dec 11 2018 07:46:15 GMT+0000 (GMT)',
|
||||
senderId: 2,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'If it takes long you can mail me at my mail address.',
|
||||
time: String(dayBeforePreviousDay),
|
||||
senderId: 11,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: false,
|
||||
isSeen: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
userId: 1,
|
||||
unseenMsgs: 1,
|
||||
messages: [
|
||||
{
|
||||
message: 'How can we help? We\'re here for you!',
|
||||
time: 'Mon Dec 10 2018 07:45:00 GMT+0000 (GMT)',
|
||||
senderId: 11,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'Hey John, I am looking for the best admin template. Could you please help me to find it out?',
|
||||
time: 'Mon Dec 10 2018 07:45:23 GMT+0000 (GMT)',
|
||||
senderId: 1,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'It should use nice Framework.',
|
||||
time: 'Mon Dec 10 2018 07:45:55 GMT+0000 (GMT)',
|
||||
senderId: 1,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'Absolutely!',
|
||||
time: 'Mon Dec 10 2018 07:46:00 GMT+0000 (GMT)',
|
||||
senderId: 11,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'Our admin is the responsive admin template.!',
|
||||
time: 'Mon Dec 10 2018 07:46:05 GMT+0000 (GMT)',
|
||||
senderId: 11,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'Looks clean and fresh UI. 😍',
|
||||
time: 'Mon Dec 10 2018 07:46:23 GMT+0000 (GMT)',
|
||||
senderId: 1,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'It\'s perfect for my next project.',
|
||||
time: 'Mon Dec 10 2018 07:46:33 GMT+0000 (GMT)',
|
||||
senderId: 1,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'How can I purchase it?',
|
||||
time: 'Mon Dec 10 2018 07:46:43 GMT+0000 (GMT)',
|
||||
senderId: 1,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'Thanks, From our official site 😇',
|
||||
time: 'Mon Dec 10 2018 07:46:53 GMT+0000 (GMT)',
|
||||
senderId: 11,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
message: 'I will purchase it for sure. 👍',
|
||||
time: String(previousDay),
|
||||
senderId: 1,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: true,
|
||||
isSeen: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------
|
||||
// GET: Return Chats Contacts and Contacts
|
||||
// ------------------------------------------------
|
||||
mock.onGet('/apps/chat/chats-and-contacts').reply(config => {
|
||||
const { q = '' } = config.params
|
||||
const qLowered = q.toLowerCase()
|
||||
|
||||
const chatsContacts = database.chats
|
||||
.map(chat => {
|
||||
const contact = JSON.parse(JSON.stringify(database.contacts.find(c => c.id === chat.userId)))
|
||||
|
||||
contact.chat = { id: chat.id, unseenMsgs: chat.unseenMsgs, lastMessage: chat.messages.at(-1) }
|
||||
|
||||
return contact
|
||||
})
|
||||
.reverse()
|
||||
|
||||
const profileUserData = database.profileUser
|
||||
|
||||
const response = {
|
||||
chatsContacts: chatsContacts.filter(c => c.fullName.toLowerCase().includes(qLowered)),
|
||||
contacts: database.contacts.filter(c => c.fullName.toLowerCase().includes(qLowered)),
|
||||
profileUser: profileUserData,
|
||||
}
|
||||
|
||||
return [200, response]
|
||||
})
|
||||
|
||||
// ------------------------------------------------
|
||||
// GET: Return Single Chat
|
||||
// ------------------------------------------------
|
||||
mock.onGet('/apps/chat/users/profile-user').reply(() => [200, database.profileUser])
|
||||
|
||||
// ------------------------------------------------
|
||||
// GET: Return Single Chat
|
||||
// ------------------------------------------------
|
||||
mock.onGet(/\/apps\/chat\/chats\/\d+/).reply(config => {
|
||||
// Get user id from URL
|
||||
const userId = Number(config.url?.substring(config.url.lastIndexOf('/') + 1))
|
||||
const chat = database.chats.find(c => c.userId === userId)
|
||||
if (chat)
|
||||
chat.unseenMsgs = 0
|
||||
|
||||
return [
|
||||
200,
|
||||
{
|
||||
chat,
|
||||
contact: database.contacts.find(c => c.id === userId),
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
// ------------------------------------------------
|
||||
// POST: Add new chat message
|
||||
// ------------------------------------------------
|
||||
mock.onPost(/\/apps\/chat\/chats\/\d+/).reply(config => {
|
||||
// Get user id from URL
|
||||
const contactId = Number(config.url?.substring(config.url.lastIndexOf('/') + 1))
|
||||
|
||||
// Get message from post data
|
||||
const { message, senderId } = JSON.parse(config.data)
|
||||
let activeChat = database.chats.find(chat => chat.userId === contactId)
|
||||
|
||||
const newMessageData = {
|
||||
message,
|
||||
time: String(new Date()),
|
||||
senderId,
|
||||
feedback: {
|
||||
isSent: true,
|
||||
isDelivered: false,
|
||||
isSeen: false,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
// If there's new chat for user create one
|
||||
let isNewChat = false
|
||||
if (activeChat === undefined) {
|
||||
isNewChat = true
|
||||
database.chats.push({
|
||||
id: genId(database.chats),
|
||||
userId: contactId,
|
||||
unseenMsgs: 0,
|
||||
messages: [],
|
||||
})
|
||||
activeChat = database.chats.at(-1)
|
||||
}
|
||||
else {
|
||||
activeChat.messages.push(newMessageData)
|
||||
}
|
||||
const response = { msg: newMessageData }
|
||||
if (isNewChat)
|
||||
response.chat = activeChat
|
||||
|
||||
return [201, response]
|
||||
})
|
2139
resources/js/@fake-db/apps/email.js
Normal file
2139
resources/js/@fake-db/apps/email.js
Normal file
File diff suppressed because it is too large
Load Diff
1041
resources/js/@fake-db/apps/invoice.js
Normal file
1041
resources/js/@fake-db/apps/invoice.js
Normal file
File diff suppressed because it is too large
Load Diff
97
resources/js/@fake-db/apps/permissions.js
Normal file
97
resources/js/@fake-db/apps/permissions.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import mock from '@/@fake-db/mock'
|
||||
import { paginateArray } from '@/@fake-db/utils'
|
||||
|
||||
const data = {
|
||||
permissions: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Management',
|
||||
assignedTo: ['administrator'],
|
||||
createdDate: '14 Apr 2021, 8:43 PM',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
assignedTo: ['administrator'],
|
||||
name: 'Manage Billing & Roles',
|
||||
createdDate: '16 Sep 2021, 5:20 PM',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Add & Remove Users',
|
||||
createdDate: '14 Oct 2021, 10:20 AM',
|
||||
assignedTo: ['administrator', 'manager'],
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Project Planning',
|
||||
createdDate: '14 Oct 2021, 10:20 AM',
|
||||
assignedTo: ['administrator', 'users', 'support'],
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Manage Email Sequences',
|
||||
createdDate: '23 Aug 2021, 2:00 PM',
|
||||
assignedTo: ['administrator', 'users', 'support'],
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Client Communication',
|
||||
createdDate: '15 Apr 2021, 11:30 AM',
|
||||
assignedTo: ['administrator', 'manager'],
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Only View',
|
||||
createdDate: '04 Dec 2021, 8:15 PM',
|
||||
assignedTo: ['administrator', 'restricted-user'],
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: 'Financial Management',
|
||||
createdDate: '25 Feb 2021, 10:30 AM',
|
||||
assignedTo: ['administrator', 'manager'],
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'Manage Others\' Tasks',
|
||||
createdDate: '04 Nov 2021, 11:45 AM',
|
||||
assignedTo: ['administrator', 'support'],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------
|
||||
// GET: Return Permissions List
|
||||
// ------------------------------------------------
|
||||
mock.onGet('/apps/permissions/data').reply(config => {
|
||||
const { q = '', options = {} } = config.params ?? {}
|
||||
const { sortBy = '', page = 1, itemsPerPage = 10 } = options
|
||||
const sort = JSON.parse(JSON.stringify(sortBy))
|
||||
const queryLowered = q.toLowerCase()
|
||||
let filteredData = data.permissions.filter(permissions => permissions.name.toLowerCase().includes(queryLowered)
|
||||
|| permissions.createdDate.toLowerCase().includes(queryLowered)
|
||||
|| permissions.assignedTo.some(i => i.toLowerCase().startsWith(queryLowered)))
|
||||
|
||||
// Sorting invoices
|
||||
if (sort.length && sort[0]?.key === 'name') {
|
||||
filteredData = filteredData.sort((a, b) => {
|
||||
if (sort[0]?.order === 'asc')
|
||||
return a.name.localeCompare(b.name)
|
||||
|
||||
return b.name.localeCompare(a.name)
|
||||
})
|
||||
}
|
||||
|
||||
// total pages
|
||||
const totalPages = Math.ceil(filteredData.length / itemsPerPage)
|
||||
|
||||
return [
|
||||
200,
|
||||
{
|
||||
permissions: paginateArray(filteredData, itemsPerPage, page),
|
||||
totalPermissions: filteredData.length,
|
||||
totalPages,
|
||||
},
|
||||
]
|
||||
})
|
773
resources/js/@fake-db/apps/user-list.js
Normal file
773
resources/js/@fake-db/apps/user-list.js
Normal file
@@ -0,0 +1,773 @@
|
||||
import mock from '@/@fake-db/mock'
|
||||
import { genId, paginateArray } from '@/@fake-db/utils'
|
||||
import avatar1 from '@images/avatars/avatar-1.png'
|
||||
import avatar2 from '@images/avatars/avatar-2.png'
|
||||
import avatar3 from '@images/avatars/avatar-3.png'
|
||||
import avatar4 from '@images/avatars/avatar-4.png'
|
||||
import avatar5 from '@images/avatars/avatar-5.png'
|
||||
import avatar6 from '@images/avatars/avatar-6.png'
|
||||
import avatar7 from '@images/avatars/avatar-7.png'
|
||||
import avatar8 from '@images/avatars/avatar-8.png'
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: 1,
|
||||
fullName: 'Galen Slixby',
|
||||
company: 'Yotz PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'El Salvador',
|
||||
contact: '(479) 232-9151',
|
||||
email: 'gslixby0@abc.net.au',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'inactive',
|
||||
billing: 'Auto Debit',
|
||||
avatar: '',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
fullName: 'Halsey Redmore',
|
||||
company: 'Skinder PVT LTD',
|
||||
role: 'author',
|
||||
country: 'Albania',
|
||||
contact: '(472) 607-9137',
|
||||
email: 'hredmore1@imgur.com',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: avatar1,
|
||||
billing: 'Manual - Paypal',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
fullName: 'Marjory Sicely',
|
||||
company: 'Oozz PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Russia',
|
||||
contact: '(321) 264-4599',
|
||||
email: 'msicely2@who.int',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'active',
|
||||
avatar: avatar1,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
fullName: 'Cyrill Risby',
|
||||
company: 'Oozz PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'China',
|
||||
contact: '(923) 690-6806',
|
||||
email: 'crisby3@wordpress.com',
|
||||
currentPlan: 'team',
|
||||
status: 'inactive',
|
||||
avatar: avatar3,
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
fullName: 'Maggy Hurran',
|
||||
company: 'Aimbo PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Pakistan',
|
||||
contact: '(669) 914-1078',
|
||||
email: 'mhurran4@yahoo.co.jp',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'pending',
|
||||
avatar: avatar1,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
fullName: 'Silvain Halstead',
|
||||
company: 'Jaxbean PVT LTD',
|
||||
role: 'author',
|
||||
country: 'China',
|
||||
contact: '(958) 973-3093',
|
||||
email: 'shalstead5@shinystat.com',
|
||||
currentPlan: 'company',
|
||||
status: 'active',
|
||||
avatar: '',
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
fullName: 'Breena Gallemore',
|
||||
company: 'Jazzy PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Canada',
|
||||
contact: '(825) 977-8152',
|
||||
email: 'bgallemore6@boston.com',
|
||||
currentPlan: 'company',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
fullName: 'Kathryne Liger',
|
||||
company: 'Pixoboo PVT LTD',
|
||||
role: 'author',
|
||||
country: 'France',
|
||||
contact: '(187) 440-0934',
|
||||
email: 'kliger7@vinaora.com',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'pending',
|
||||
avatar: avatar4,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
fullName: 'Franz Scotfurth',
|
||||
company: 'Tekfly PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'China',
|
||||
contact: '(978) 146-5443',
|
||||
email: 'fscotfurth8@dailymotion.com',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: avatar2,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
fullName: 'Jillene Bellany',
|
||||
company: 'Gigashots PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Jamaica',
|
||||
contact: '(589) 284-6732',
|
||||
email: 'jbellany9@kickstarter.com',
|
||||
currentPlan: 'company',
|
||||
status: 'inactive',
|
||||
avatar: avatar5,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
fullName: 'Jonah Wharlton',
|
||||
company: 'Eare PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'United States',
|
||||
contact: '(176) 532-6824',
|
||||
email: 'jwharltona@oakley.com',
|
||||
currentPlan: 'team',
|
||||
status: 'inactive',
|
||||
avatar: avatar4,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
fullName: 'Seth Hallam',
|
||||
company: 'Yakitri PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Peru',
|
||||
contact: '(234) 464-0600',
|
||||
email: 'shallamb@hugedomains.com',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: avatar5,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
fullName: 'Yoko Pottie',
|
||||
company: 'Leenti PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Philippines',
|
||||
contact: '(907) 284-5083',
|
||||
email: 'ypottiec@privacy.gov.au',
|
||||
currentPlan: 'basic',
|
||||
status: 'inactive',
|
||||
avatar: avatar7,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
fullName: 'Maximilianus Krause',
|
||||
company: 'Digitube PVT LTD',
|
||||
role: 'author',
|
||||
country: 'Democratic Republic of the Congo',
|
||||
contact: '(167) 135-7392',
|
||||
email: 'mkraused@stanford.edu',
|
||||
currentPlan: 'team',
|
||||
status: 'active',
|
||||
avatar: avatar6,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
fullName: 'Zsazsa McCleverty',
|
||||
company: 'Kaymbo PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'France',
|
||||
contact: '(317) 409-6565',
|
||||
email: 'zmcclevertye@soundcloud.com',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'active',
|
||||
avatar: avatar2,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
fullName: 'Bentlee Emblin',
|
||||
company: 'Yambee PVT LTD',
|
||||
role: 'author',
|
||||
country: 'Spain',
|
||||
contact: '(590) 606-1056',
|
||||
email: 'bemblinf@wired.com',
|
||||
currentPlan: 'company',
|
||||
status: 'active',
|
||||
avatar: avatar6,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 17,
|
||||
fullName: 'Brockie Myles',
|
||||
company: 'Wikivu PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Poland',
|
||||
contact: '(553) 225-9905',
|
||||
email: 'bmylesg@amazon.com',
|
||||
currentPlan: 'basic',
|
||||
status: 'active',
|
||||
avatar: '',
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 18,
|
||||
fullName: 'Bertha Biner',
|
||||
company: 'Twinte PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'Yemen',
|
||||
contact: '(901) 916-9287',
|
||||
email: 'bbinerh@mozilla.com',
|
||||
currentPlan: 'team',
|
||||
status: 'active',
|
||||
avatar: avatar7,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 19,
|
||||
fullName: 'Travus Bruntjen',
|
||||
company: 'Cogidoo PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'France',
|
||||
contact: '(524) 586-6057',
|
||||
email: 'tbruntjeni@sitemeter.com',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'active',
|
||||
avatar: '',
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 20,
|
||||
fullName: 'Wesley Burland',
|
||||
company: 'Bubblemix PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'Honduras',
|
||||
contact: '(569) 683-1292',
|
||||
email: 'wburlandj@uiuc.edu',
|
||||
currentPlan: 'team',
|
||||
status: 'inactive',
|
||||
avatar: avatar6,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 21,
|
||||
fullName: 'Selina Kyle',
|
||||
company: 'Wayne Enterprises',
|
||||
role: 'admin',
|
||||
country: 'USA',
|
||||
contact: '(829) 537-0057',
|
||||
email: 'irena.dubrovna@wayne.com',
|
||||
currentPlan: 'team',
|
||||
status: 'active',
|
||||
avatar: avatar1,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
fullName: 'Jameson Lyster',
|
||||
company: 'Quaxo PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'Ukraine',
|
||||
contact: '(593) 624-0222',
|
||||
email: 'jlysterl@guardian.co.uk',
|
||||
currentPlan: 'company',
|
||||
status: 'inactive',
|
||||
avatar: avatar8,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 23,
|
||||
fullName: 'Kare Skitterel',
|
||||
company: 'Ainyx PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Poland',
|
||||
contact: '(254) 845-4107',
|
||||
email: 'kskitterelm@ainyx.com',
|
||||
currentPlan: 'basic',
|
||||
status: 'pending',
|
||||
avatar: avatar3,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 24,
|
||||
fullName: 'Cleavland Hatherleigh',
|
||||
company: 'Flipopia PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'Brazil',
|
||||
contact: '(700) 783-7498',
|
||||
email: 'chatherleighn@washington.edu',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: avatar2,
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 25,
|
||||
fullName: 'Adeline Micco',
|
||||
company: 'Topicware PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'France',
|
||||
contact: '(227) 598-1841',
|
||||
email: 'amiccoo@whitehouse.gov',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 26,
|
||||
fullName: 'Hugh Hasson',
|
||||
company: 'Skinix PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'China',
|
||||
contact: '(582) 516-1324',
|
||||
email: 'hhassonp@bizjournals.com',
|
||||
currentPlan: 'basic',
|
||||
status: 'inactive',
|
||||
avatar: avatar4,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 27,
|
||||
fullName: 'Germain Jacombs',
|
||||
company: 'Youopia PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'Zambia',
|
||||
contact: '(137) 467-5393',
|
||||
email: 'gjacombsq@jigsy.com',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'active',
|
||||
avatar: avatar5,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 28,
|
||||
fullName: 'Bree Kilday',
|
||||
company: 'Jetpulse PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Portugal',
|
||||
contact: '(412) 476-0854',
|
||||
email: 'bkildayr@mashable.com',
|
||||
currentPlan: 'team',
|
||||
status: 'active',
|
||||
avatar: '',
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 29,
|
||||
fullName: 'Candice Pinyon',
|
||||
company: 'Kare PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Sweden',
|
||||
contact: '(170) 683-1520',
|
||||
email: 'cpinyons@behance.net',
|
||||
currentPlan: 'team',
|
||||
status: 'active',
|
||||
avatar: avatar7,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 30,
|
||||
fullName: 'Isabel Mallindine',
|
||||
company: 'Voomm PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Slovenia',
|
||||
contact: '(332) 803-1983',
|
||||
email: 'imallindinet@shinystat.com',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 31,
|
||||
fullName: 'Gwendolyn Meineken',
|
||||
company: 'Oyondu PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'Moldova',
|
||||
contact: '(551) 379-7460',
|
||||
email: 'gmeinekenu@hc360.com',
|
||||
currentPlan: 'basic',
|
||||
status: 'pending',
|
||||
avatar: avatar1,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 32,
|
||||
fullName: 'Rafaellle Snowball',
|
||||
company: 'Fivespan PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'Philippines',
|
||||
contact: '(974) 829-0911',
|
||||
email: 'rsnowballv@indiegogo.com',
|
||||
currentPlan: 'basic',
|
||||
status: 'pending',
|
||||
avatar: avatar5,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 33,
|
||||
fullName: 'Rochette Emer',
|
||||
company: 'Thoughtworks PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'North Korea',
|
||||
contact: '(841) 889-3339',
|
||||
email: 'remerw@blogtalkradio.com',
|
||||
currentPlan: 'basic',
|
||||
status: 'active',
|
||||
avatar: avatar8,
|
||||
billing: 'Manual - Paypal',
|
||||
},
|
||||
{
|
||||
id: 34,
|
||||
fullName: 'Ophelie Fibbens',
|
||||
company: 'Jaxbean PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Indonesia',
|
||||
contact: '(764) 885-7351',
|
||||
email: 'ofibbensx@booking.com',
|
||||
currentPlan: 'company',
|
||||
status: 'active',
|
||||
avatar: avatar4,
|
||||
billing: 'Manual - Paypal',
|
||||
},
|
||||
{
|
||||
id: 35,
|
||||
fullName: 'Stephen MacGilfoyle',
|
||||
company: 'Browseblab PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Japan',
|
||||
contact: '(350) 589-8520',
|
||||
email: 'smacgilfoyley@bigcartel.com',
|
||||
currentPlan: 'company',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Manual - Paypal',
|
||||
},
|
||||
{
|
||||
id: 36,
|
||||
fullName: 'Bradan Rosebotham',
|
||||
company: 'Agivu PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Belarus',
|
||||
contact: '(882) 933-2180',
|
||||
email: 'brosebothamz@tripadvisor.com',
|
||||
currentPlan: 'team',
|
||||
status: 'inactive',
|
||||
avatar: '',
|
||||
billing: 'Manual - Paypal',
|
||||
},
|
||||
{
|
||||
id: 37,
|
||||
fullName: 'Skip Hebblethwaite',
|
||||
company: 'Katz PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'Canada',
|
||||
contact: '(610) 343-1024',
|
||||
email: 'shebblethwaite10@arizona.edu',
|
||||
currentPlan: 'company',
|
||||
status: 'inactive',
|
||||
avatar: avatar1,
|
||||
billing: 'Manual - Paypal',
|
||||
},
|
||||
{
|
||||
id: 38,
|
||||
fullName: 'Moritz Piccard',
|
||||
company: 'Twitternation PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Croatia',
|
||||
contact: '(365) 277-2986',
|
||||
email: 'mpiccard11@vimeo.com',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'inactive',
|
||||
avatar: avatar1,
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 39,
|
||||
fullName: 'Tyne Widmore',
|
||||
company: 'Yombu PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Finland',
|
||||
contact: '(531) 731-0928',
|
||||
email: 'twidmore12@bravesites.com',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
{
|
||||
id: 40,
|
||||
fullName: 'Florenza Desporte',
|
||||
company: 'Kamba PVT LTD',
|
||||
role: 'author',
|
||||
country: 'Ukraine',
|
||||
contact: '(312) 104-2638',
|
||||
email: 'fdesporte13@omniture.com',
|
||||
currentPlan: 'company',
|
||||
status: 'active',
|
||||
avatar: avatar6,
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
{
|
||||
id: 41,
|
||||
fullName: 'Edwina Baldetti',
|
||||
company: 'Dazzlesphere PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Haiti',
|
||||
contact: '(315) 329-3578',
|
||||
email: 'ebaldetti14@theguardian.com',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Manual - Cash',
|
||||
},
|
||||
{
|
||||
id: 42,
|
||||
fullName: 'Benedetto Rossiter',
|
||||
company: 'Mybuzz PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'Indonesia',
|
||||
contact: '(323) 175-6741',
|
||||
email: 'brossiter15@craigslist.org',
|
||||
currentPlan: 'team',
|
||||
status: 'inactive',
|
||||
avatar: '',
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
{
|
||||
id: 43,
|
||||
fullName: 'Micaela McNirlan',
|
||||
company: 'Tambee PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'Indonesia',
|
||||
contact: '(242) 952-0916',
|
||||
email: 'mmcnirlan16@hc360.com',
|
||||
currentPlan: 'basic',
|
||||
status: 'inactive',
|
||||
avatar: '',
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
{
|
||||
id: 44,
|
||||
fullName: 'Vladamir Koschek',
|
||||
company: 'Centimia PVT LTD',
|
||||
role: 'author',
|
||||
country: 'Guatemala',
|
||||
contact: '(531) 758-8335',
|
||||
email: 'vkoschek17@abc.net.au',
|
||||
currentPlan: 'team',
|
||||
status: 'active',
|
||||
avatar: '',
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 45,
|
||||
fullName: 'Corrie Perot',
|
||||
company: 'Flipopia PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'China',
|
||||
contact: '(659) 385-6808',
|
||||
email: 'cperot18@goo.ne.jp',
|
||||
currentPlan: 'team',
|
||||
status: 'pending',
|
||||
avatar: avatar3,
|
||||
billing: 'Manual - Paypal',
|
||||
},
|
||||
{
|
||||
id: 46,
|
||||
fullName: 'Saunder Offner',
|
||||
company: 'Skalith PVT LTD',
|
||||
role: 'maintainer',
|
||||
country: 'Poland',
|
||||
contact: '(200) 586-2264',
|
||||
email: 'soffner19@mac.com',
|
||||
currentPlan: 'enterprise',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 47,
|
||||
fullName: 'Karena Courtliff',
|
||||
company: 'Feedfire PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'China',
|
||||
contact: '(478) 199-0020',
|
||||
email: 'kcourtliff1a@bbc.co.uk',
|
||||
currentPlan: 'basic',
|
||||
status: 'active',
|
||||
avatar: avatar1,
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
{
|
||||
id: 48,
|
||||
fullName: 'Onfre Wind',
|
||||
company: 'Thoughtmix PVT LTD',
|
||||
role: 'admin',
|
||||
country: 'Ukraine',
|
||||
contact: '(344) 262-7270',
|
||||
email: 'owind1b@yandex.ru',
|
||||
currentPlan: 'basic',
|
||||
status: 'pending',
|
||||
avatar: '',
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
{
|
||||
id: 49,
|
||||
fullName: 'Paulie Durber',
|
||||
company: 'Babbleblab PVT LTD',
|
||||
role: 'subscriber',
|
||||
country: 'Sweden',
|
||||
contact: '(694) 676-1275',
|
||||
email: 'pdurber1c@gov.uk',
|
||||
currentPlan: 'team',
|
||||
status: 'inactive',
|
||||
avatar: '',
|
||||
billing: 'Auto Debit',
|
||||
},
|
||||
{
|
||||
id: 50,
|
||||
fullName: 'Beverlie Krabbe',
|
||||
company: 'Kaymbo PVT LTD',
|
||||
role: 'editor',
|
||||
country: 'China',
|
||||
contact: '(397) 294-5153',
|
||||
email: 'bkrabbe1d@home.pl',
|
||||
currentPlan: 'company',
|
||||
status: 'active',
|
||||
avatar: avatar2,
|
||||
billing: 'Manual - Credit Card',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
// 👉 return users
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
mock.onGet('/apps/users/list').reply(config => {
|
||||
const { q = '', role = null, plan = null, status = null, options = {} } = config.params ?? {}
|
||||
const { sortBy = '', itemsPerPage = 10, page = 1 } = options
|
||||
const queryLower = q.toLowerCase()
|
||||
|
||||
// filter users
|
||||
let filteredUsers = users.filter(user => ((user.fullName.toLowerCase().includes(queryLower) || user.email.toLowerCase().includes(queryLower)) && user.role === (role || user.role) && user.currentPlan === (plan || user.currentPlan) && user.status === (status || user.status))).reverse()
|
||||
|
||||
// sort users
|
||||
const sort = JSON.parse(JSON.stringify(sortBy))
|
||||
if (sort.length) {
|
||||
if (sort[0]?.key === 'user') {
|
||||
filteredUsers = filteredUsers.sort((a, b) => {
|
||||
if (sort[0]?.order === 'asc')
|
||||
return a.fullName.localeCompare(b.fullName)
|
||||
else
|
||||
return b.fullName.localeCompare(a.fullName)
|
||||
})
|
||||
}
|
||||
if (sort[0]?.key === 'billing') {
|
||||
filteredUsers = filteredUsers.sort((a, b) => {
|
||||
if (sort[0]?.order === 'asc')
|
||||
return a.billing.localeCompare(b.billing)
|
||||
else
|
||||
return b.billing.localeCompare(a.billing)
|
||||
})
|
||||
}
|
||||
if (sort[0]?.key === 'role') {
|
||||
filteredUsers = filteredUsers.sort((a, b) => {
|
||||
if (sort[0]?.order === 'asc')
|
||||
return a.role.localeCompare(b.role)
|
||||
else
|
||||
return b.role.localeCompare(a.role)
|
||||
})
|
||||
}
|
||||
if (sort[0]?.key === 'plan') {
|
||||
filteredUsers = filteredUsers.sort((a, b) => {
|
||||
if (sort[0]?.order === 'asc')
|
||||
return a.currentPlan.localeCompare(b.currentPlan)
|
||||
else
|
||||
return b.currentPlan.localeCompare(a.currentPlan)
|
||||
})
|
||||
}
|
||||
if (sort[0]?.key === 'status') {
|
||||
filteredUsers = filteredUsers.sort((a, b) => {
|
||||
if (sort[0]?.order === 'asc')
|
||||
return a.status.localeCompare(b.status)
|
||||
else
|
||||
return b.status.localeCompare(a.status)
|
||||
})
|
||||
}
|
||||
}
|
||||
const totalUsers = filteredUsers.length
|
||||
|
||||
// total pages
|
||||
const totalPages = Math.ceil(totalUsers / itemsPerPage)
|
||||
|
||||
return [200, { users: paginateArray(filteredUsers, itemsPerPage, page), totalPages, totalUsers, page: page > Math.ceil(totalUsers / itemsPerPage) ? 1 : page }]
|
||||
})
|
||||
|
||||
// 👉 Add user
|
||||
mock.onPost('/apps/users/user').reply(config => {
|
||||
const { user } = JSON.parse(config.data)
|
||||
|
||||
user.id = genId(users)
|
||||
users.push(user)
|
||||
|
||||
return [201, { user }]
|
||||
})
|
||||
|
||||
// 👉 Get Single user
|
||||
mock.onGet(/\/apps\/users\/\d+/).reply(config => {
|
||||
// Get event id from URL
|
||||
const userId = config.url?.substring(config.url.lastIndexOf('/') + 1)
|
||||
|
||||
// Convert Id to number
|
||||
const Id = Number(userId)
|
||||
const userIndex = users.findIndex(e => e.id === Id)
|
||||
const user = users[userIndex]
|
||||
|
||||
Object.assign(user, {
|
||||
taskDone: 1230,
|
||||
projectDone: 568,
|
||||
taxId: 'Tax-8894',
|
||||
language: 'English',
|
||||
})
|
||||
if (user)
|
||||
return [200, user]
|
||||
|
||||
return [404]
|
||||
})
|
||||
mock.onDelete(/\/apps\/users\/\d+/).reply(config => {
|
||||
// Get user id from URL
|
||||
const userId = config.url?.substring(config.url.lastIndexOf('/') + 1)
|
||||
|
||||
// Convert Id to number
|
||||
const Id = Number(userId)
|
||||
const userIndex = users.findIndex(e => e.id === Id)
|
||||
if (userIndex >= 0) {
|
||||
users.splice(userIndex, 1)
|
||||
|
||||
return [200]
|
||||
}
|
||||
|
||||
return [400]
|
||||
})
|
Reference in New Issue
Block a user