Template
first commit
This commit is contained in:
Executable
+171
@@ -0,0 +1,171 @@
|
||||
// project imports
|
||||
import mock from '../../mockAdapter';
|
||||
import user1 from '@/assets/images/profile/user-1.jpg';
|
||||
import user8 from '@/assets/images/profile/user-2.jpg';
|
||||
import user3 from '@/assets/images/profile/user-3.jpg';
|
||||
import user4 from '@/assets/images/profile/user-4.jpg';
|
||||
import user5 from '@/assets/images/profile/user-5.jpg';
|
||||
import user6 from '@/assets/images/profile/user-6.jpg';
|
||||
import user7 from '@/assets/images/profile/user-7.jpg';
|
||||
import user11 from '@/assets/images/profile/user-3.jpg';
|
||||
import user12 from '@/assets/images/profile/user-4.jpg';
|
||||
import user9 from '@/assets/images/profile/user-5.jpg';
|
||||
import user10 from '@/assets/images/profile/user-2.jpg';
|
||||
|
||||
// types
|
||||
export type KeyedObject = {
|
||||
[key: string]: string | number | KeyedObject | any;
|
||||
};
|
||||
|
||||
// followers list
|
||||
|
||||
const followers: KeyedObject[] = [
|
||||
{
|
||||
id: '#1Followers_Barney',
|
||||
avatar: user6,
|
||||
name: 'Barney',
|
||||
location: 'Handburgh',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#2Followers_Thea',
|
||||
avatar: user3,
|
||||
name: 'Thea',
|
||||
location: 'New jana',
|
||||
follow: 2
|
||||
},
|
||||
{
|
||||
id: '#3Followers_Guiseppe',
|
||||
avatar: user7,
|
||||
name: 'Guiseppe',
|
||||
location: 'Jenkinsstad',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#4Followers_Henderson',
|
||||
avatar: user8,
|
||||
name: 'Henderson',
|
||||
location: 'South Antonina',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#5Followers_Maddison',
|
||||
avatar: user6,
|
||||
name: 'Maddison',
|
||||
location: 'New Dorthy',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#6Followers_Wilber',
|
||||
avatar: user1,
|
||||
name: 'Wilber',
|
||||
location: 'Twilahsven',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#7Followers_Hayden',
|
||||
avatar: user4,
|
||||
name: 'Hayden',
|
||||
location: 'Darrelshaire',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#8Followers_Lloyd',
|
||||
avatar: user10,
|
||||
name: 'Lloyd',
|
||||
location: 'New Credrick',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#9Followers_Kris',
|
||||
avatar: user8,
|
||||
name: 'Kris',
|
||||
location: 'New Dianna',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#10Followers_Kyler',
|
||||
avatar: user11,
|
||||
name: 'Kyler',
|
||||
location: 'Murraymouth',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#11Followers_Pamela',
|
||||
avatar: user3,
|
||||
name: 'Pamela',
|
||||
location: 'Murraymouth',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#12Followers_Betty',
|
||||
avatar: user6,
|
||||
name: 'John Doe',
|
||||
location: 'North Zole',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#13Followers_Anthony',
|
||||
avatar: user5,
|
||||
name: 'Anthony',
|
||||
location: 'Lake Judy',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#14Followers_Reggie',
|
||||
avatar: user12,
|
||||
name: 'Reggie',
|
||||
location: 'Kailynland',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#15Followers_Francesca',
|
||||
avatar: user1,
|
||||
name: 'Francesca',
|
||||
location: 'Pagacview',
|
||||
follow: 2
|
||||
},
|
||||
{
|
||||
id: '#16Followers_Carmel',
|
||||
avatar: user9,
|
||||
name: 'Carmel',
|
||||
location: 'Port Lerashire',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#17Followers_Darwin',
|
||||
avatar: user4,
|
||||
name: 'Darwin',
|
||||
location: 'North Jacquesside',
|
||||
follow: 2
|
||||
},
|
||||
{
|
||||
id: '#18Followers_Kaylin',
|
||||
avatar: user3,
|
||||
name: 'Kaylin',
|
||||
location: 'Bergstrombury',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#19Followers_Kamryn',
|
||||
avatar: user7,
|
||||
name: 'Kamryn',
|
||||
location: 'South Norma',
|
||||
follow: 1
|
||||
},
|
||||
{
|
||||
id: '#20Followers_Madelyn',
|
||||
avatar: user8,
|
||||
name: 'Madelyn',
|
||||
location: 'Port Opheliamouth',
|
||||
follow: 1
|
||||
}
|
||||
];
|
||||
|
||||
// ==============================|| MOCK SERVICES ||============================== //
|
||||
|
||||
mock.onGet('/api/followers/list').reply(200, { followers });
|
||||
|
||||
// mock.onGet('/api/followers/list').reply(() => {
|
||||
// return [200, followers];
|
||||
// });
|
||||
Executable
+192
@@ -0,0 +1,192 @@
|
||||
// project imports
|
||||
import mock from '../../mockAdapter';
|
||||
import { Chance } from 'chance';
|
||||
|
||||
|
||||
import user1 from '@/assets/images/profile/user-10.jpg';
|
||||
import user2 from '@/assets/images/profile/user-2.jpg';
|
||||
import user8 from '@/assets/images/profile/user-6.jpg';
|
||||
import user3 from '@/assets/images/profile/user-3.jpg';
|
||||
import user4 from '@/assets/images/profile/user-4.jpg';
|
||||
import user5 from '@/assets/images/profile/user-5.jpg';
|
||||
import user6 from '@/assets/images/profile/user-6.jpg';
|
||||
import user7 from '@/assets/images/profile/user-7.jpg';
|
||||
import user11 from '@/assets/images/profile/user-3.jpg';
|
||||
import user12 from '@/assets/images/profile/user-4.jpg';
|
||||
import user9 from '@/assets/images/profile/user-5.jpg';
|
||||
import user10 from '@/assets/images/profile/user-2.jpg';
|
||||
|
||||
const chance = new Chance();
|
||||
|
||||
// types
|
||||
export type KeyedObject = {
|
||||
[key: string]: string | number | KeyedObject | any;
|
||||
};
|
||||
|
||||
// friends list
|
||||
const friends: KeyedObject[] = [
|
||||
{
|
||||
id: '#1Friends_Barney',
|
||||
avatar: user1,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 10
|
||||
},
|
||||
{
|
||||
id: '#2Friends_Thea',
|
||||
avatar: user2,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 89
|
||||
},
|
||||
{
|
||||
id: '#3Friends_Guiseppe',
|
||||
avatar: user3,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 65
|
||||
},
|
||||
{
|
||||
id: '#4Friends_Henderson',
|
||||
avatar: user4,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 1
|
||||
},
|
||||
{
|
||||
id: '#5Friends_Maddison',
|
||||
avatar: user5,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 14
|
||||
},
|
||||
{
|
||||
id: '#6Friends_Wilber',
|
||||
avatar: user6,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 36
|
||||
},
|
||||
{
|
||||
id: '#7Friends_Hayden',
|
||||
avatar: user7,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 106
|
||||
},
|
||||
{
|
||||
id: '#8Friends_Lloyd',
|
||||
avatar: user8,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 10
|
||||
},
|
||||
{
|
||||
id: '#9Friends_Kris',
|
||||
avatar: user9,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 0
|
||||
},
|
||||
{
|
||||
id: '#10Friends_Kyler',
|
||||
avatar: user10,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 48
|
||||
},
|
||||
{
|
||||
id: '#11Friends_Pamela',
|
||||
avatar: user11,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 72
|
||||
},
|
||||
{
|
||||
id: '#12Friends_Betty',
|
||||
avatar: user12,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 99
|
||||
},
|
||||
{
|
||||
id: '#13Friends_Anthony',
|
||||
avatar: user1,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 78
|
||||
},
|
||||
{
|
||||
id: '#14Friends_Reggie',
|
||||
avatar: user3,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 1
|
||||
},
|
||||
{
|
||||
id: '#15Friends_Francesca',
|
||||
avatar: user4,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 68
|
||||
},
|
||||
{
|
||||
id: '#16Friends_Carmel',
|
||||
avatar: user5,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 15
|
||||
},
|
||||
{
|
||||
id: '#17Friends_Darwin',
|
||||
avatar: user6,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 10
|
||||
},
|
||||
{
|
||||
id: '#18Friends_Kaylin',
|
||||
avatar: user7,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 36
|
||||
},
|
||||
{
|
||||
id: '#19Friends_Kamryn',
|
||||
avatar: user8,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 55
|
||||
},
|
||||
{
|
||||
id: '#20Friends_Madelyn',
|
||||
avatar: user9,
|
||||
name: chance.name(),
|
||||
location: chance.country({ full: true }),
|
||||
role: chance.profession(),
|
||||
mutual: 78
|
||||
}
|
||||
];
|
||||
|
||||
// ==============================|| MOCK SERVICES ||============================== //
|
||||
|
||||
mock.onGet('/api/friends/list').reply(200, { friends });
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
// project imports
|
||||
import mock from '../../mockAdapter';
|
||||
// assets
|
||||
import image1 from '@/assets/images/products/s1.jpg';
|
||||
import image2 from '@/assets/images/products/s2.jpg';
|
||||
import image3 from '@/assets/images/products/s3.jpg';
|
||||
import image4 from '@/assets/images/products/s4.jpg';
|
||||
import image5 from '@/assets/images/products/s5.jpg';
|
||||
import image6 from '@/assets/images/products/s6.jpg';
|
||||
import image7 from '@/assets/images/products/s7.jpg';
|
||||
import image8 from '@/assets/images/products/s8.jpg';
|
||||
import image9 from '@/assets/images/products/s9.jpg';
|
||||
import image10 from '@/assets/images/products/s10.jpg';
|
||||
import image11 from '@/assets/images/products/s11.jpg';
|
||||
import image12 from '@/assets/images/products/s12.jpg';
|
||||
|
||||
// types
|
||||
export type KeyedObject = {
|
||||
[key: string]: string | number | KeyedObject | any;
|
||||
};
|
||||
|
||||
// gallery components
|
||||
|
||||
const gallery: KeyedObject[] = [
|
||||
{
|
||||
id: '#1Gallery',
|
||||
image: image1,
|
||||
title: '1080p_table_denar.pdf',
|
||||
dateTime: 'Tue Aug 24 2021'
|
||||
},
|
||||
{
|
||||
id: '#2Gallery',
|
||||
image: image2,
|
||||
title: 'handmade.mp2',
|
||||
dateTime: 'Fri Apr 30 2021'
|
||||
},
|
||||
{
|
||||
id: '#3Gallery',
|
||||
image: image3,
|
||||
title: 'granite_cheese.wav',
|
||||
dateTime: 'Fri Jun 25 2021'
|
||||
},
|
||||
{
|
||||
id: '#4Gallery',
|
||||
image: image4,
|
||||
title: 'invoice.mpg',
|
||||
dateTime: 'Sat Oct 23 2021'
|
||||
},
|
||||
{
|
||||
id: '#5Gallery',
|
||||
image: image5,
|
||||
title: 'benchmark_forge.m1v',
|
||||
dateTime: 'Fri Jan 21 2022'
|
||||
},
|
||||
{
|
||||
id: '#6Gallery',
|
||||
image: image6,
|
||||
title: 'violet_withdrawal.png',
|
||||
dateTime: 'Wed Sep 22 2021'
|
||||
},
|
||||
{
|
||||
id: '#7Gallery',
|
||||
image: image7,
|
||||
title: 'web_readiness.mpeg',
|
||||
dateTime: 'Mon Jul 12 2021'
|
||||
},
|
||||
{
|
||||
id: '#8Gallery',
|
||||
image: image8,
|
||||
title: 'zimbabwe.htm',
|
||||
dateTime: 'Sat Mar 20 2021'
|
||||
},
|
||||
{
|
||||
id: '#9Gallery',
|
||||
image: image9,
|
||||
title: 'circuit.m3a',
|
||||
dateTime: 'Tue Jan 18 2022'
|
||||
},
|
||||
{
|
||||
id: '#10Gallery',
|
||||
image: image10,
|
||||
title: 'data_red.png',
|
||||
dateTime: 'Sun Apr 04 2021'
|
||||
},
|
||||
{
|
||||
id: '#11Gallery',
|
||||
image: image11,
|
||||
title: 'handcrafted.html',
|
||||
dateTime: 'Tue May 25 2021'
|
||||
},
|
||||
{
|
||||
id: '#12Gallery',
|
||||
image: image12,
|
||||
title: 'hacking_games.pdf',
|
||||
dateTime: 'Tue Oct 19 2021'
|
||||
}
|
||||
];
|
||||
|
||||
// ==============================|| MOCK SERVICES ||============================== //
|
||||
|
||||
mock.onGet('/api/gallery/list').reply(200, { gallery });
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
// project imports
|
||||
import mock from '../../mockAdapter';
|
||||
// assets
|
||||
import image1 from '@/assets/images/products/s1.jpg';
|
||||
import image2 from '@/assets/images/products/s2.jpg';
|
||||
import image3 from '@/assets/images/products/s3.jpg';
|
||||
import image4 from '@/assets/images/products/s4.jpg';
|
||||
import image5 from '@/assets/images/products/s5.jpg';
|
||||
import image6 from '@/assets/images/products/s6.jpg';
|
||||
import image7 from '@/assets/images/products/s7.jpg';
|
||||
import image8 from '@/assets/images/products/s8.jpg';
|
||||
import image9 from '@/assets/images/products/s9.jpg';
|
||||
import image10 from '@/assets/images/products/s10.jpg';
|
||||
import image11 from '@/assets/images/products/s11.jpg';
|
||||
import image12 from '@/assets/images/products/s12.jpg';
|
||||
|
||||
// types
|
||||
export type KeyedObject = {
|
||||
[key: string]: string | number | KeyedObject | any;
|
||||
};
|
||||
|
||||
// Photos components
|
||||
|
||||
const photos: KeyedObject[] = [
|
||||
{
|
||||
id: '#1Photos',
|
||||
avatar: image1,
|
||||
},
|
||||
{
|
||||
id: '#2Photos',
|
||||
avatar: image2,
|
||||
},
|
||||
{
|
||||
id: '#3Photos',
|
||||
avatar: image3,
|
||||
},
|
||||
{
|
||||
id: '#4Photos',
|
||||
avatar: image4,
|
||||
},
|
||||
{
|
||||
id: '#5Photos',
|
||||
avatar: image5,
|
||||
},
|
||||
{
|
||||
id: '#6Photos',
|
||||
avatar: image6,
|
||||
},
|
||||
{
|
||||
id: '#7Photos',
|
||||
avatar: image7,
|
||||
},
|
||||
{
|
||||
id: '#8Photos',
|
||||
avatar: image8,
|
||||
},
|
||||
{
|
||||
id: '#9Photos',
|
||||
avatar: image9,
|
||||
},
|
||||
{
|
||||
id: '#10Photos',
|
||||
avatar: image10,
|
||||
},
|
||||
{
|
||||
id: '#11Photos',
|
||||
avatar: image11,
|
||||
},
|
||||
{
|
||||
id: '#12Photos',
|
||||
avatar: image12,
|
||||
},
|
||||
];
|
||||
|
||||
// ==============================|| MOCK SERVICES ||============================== //
|
||||
|
||||
mock.onGet('/api/photos').reply(200, { photos });
|
||||
Executable
+305
@@ -0,0 +1,305 @@
|
||||
// project imports
|
||||
import mock from '../../mockAdapter';
|
||||
import { Chance } from 'chance';
|
||||
|
||||
// types
|
||||
import type { Post } from '@/types/apps/PostType';
|
||||
|
||||
// assets
|
||||
import image1 from '@/assets/images/products/s1.jpg';
|
||||
import image2 from '@/assets/images/products/s2.jpg';
|
||||
import image4 from '@/assets/images/products/s4.jpg';
|
||||
import user1 from '@/assets/images/profile/user-1.jpg';
|
||||
import user2 from '@/assets/images/profile/user-2.jpg';
|
||||
import user3 from '@/assets/images/profile/user-3.jpg';
|
||||
import user4 from '@/assets/images/profile/user-4.jpg';
|
||||
import user5 from '@/assets/images/profile/user-5.jpg';
|
||||
|
||||
const chance = new Chance();
|
||||
|
||||
// social profile
|
||||
let posts: Post[] = [
|
||||
{
|
||||
id: '#1POST_MATHEW',
|
||||
profile: {
|
||||
id: '#52MATHEW',
|
||||
avatar: user1,
|
||||
name: 'David McMichael',
|
||||
time: '15 min ago'
|
||||
},
|
||||
data: {
|
||||
content: chance.paragraph({ sentences: 2 }),
|
||||
images: [
|
||||
{
|
||||
img: image1,
|
||||
featured: true
|
||||
}
|
||||
],
|
||||
likes: {
|
||||
like: true,
|
||||
value: 102
|
||||
},
|
||||
comments: [
|
||||
{
|
||||
id: '#3COMMENTMATHEWE',
|
||||
profile: {
|
||||
id: '#52MATHEW',
|
||||
avatar: user3,
|
||||
name: 'Deran Mac',
|
||||
time: '8 mins ago '
|
||||
},
|
||||
data: {
|
||||
comment: chance.paragraph({ sentences: 1 }),
|
||||
likes: {
|
||||
like: true,
|
||||
value: 55
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '#2COMMENT_MATHEW',
|
||||
profile: {
|
||||
id: '#52MATHEW',
|
||||
avatar: user4,
|
||||
name: 'Jonathan Bg',
|
||||
time: '5 mins ago '
|
||||
},
|
||||
data: {
|
||||
comment:
|
||||
chance.paragraph({ sentences: 1 }),
|
||||
likes: {
|
||||
like: false,
|
||||
value: 68
|
||||
},
|
||||
replies: [
|
||||
{
|
||||
id: '#1REPLY_MATHEW',
|
||||
profile: {
|
||||
id: '#52MATHEW',
|
||||
avatar: user5,
|
||||
name: 'Carry minati',
|
||||
time: 'just now '
|
||||
},
|
||||
data: {
|
||||
comment: chance.paragraph({ sentences: 1 }),
|
||||
likes: {
|
||||
like: true,
|
||||
value: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '#4POST_CARRY',
|
||||
profile: {
|
||||
id: '#52CARRY',
|
||||
avatar: user1,
|
||||
name: 'Carry Minati',
|
||||
time: 'now'
|
||||
},
|
||||
data: {
|
||||
content: chance.paragraph({ sentences: 2 }),
|
||||
images: [],
|
||||
likes: {
|
||||
like: false,
|
||||
value: 67
|
||||
},
|
||||
comments: []
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '#2POST_GENELIA',
|
||||
profile: {
|
||||
id: '#52GENELIA',
|
||||
avatar: user2,
|
||||
name: 'Genelia Desouza',
|
||||
time: '15 min ago '
|
||||
},
|
||||
data: {
|
||||
content: chance.paragraph({ sentences: 1 }),
|
||||
images: [
|
||||
{
|
||||
img: image2,
|
||||
title: 'Image Title'
|
||||
},
|
||||
{
|
||||
img: image4,
|
||||
title: 'Painter'
|
||||
}
|
||||
],
|
||||
likes: {
|
||||
like: false,
|
||||
value: 320
|
||||
},
|
||||
comments: [
|
||||
{
|
||||
id: '#2COMMENT_GENELIA',
|
||||
profile: {
|
||||
id: '#52GENELIA',
|
||||
avatar: user3,
|
||||
name: 'Ritesh Deshmukh',
|
||||
time: '15 min ago '
|
||||
},
|
||||
data: {
|
||||
comment:
|
||||
chance.paragraph({ sentences: 1 }),
|
||||
likes: {
|
||||
like: true,
|
||||
value: 65
|
||||
},
|
||||
replies: []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '#3POST_Mathew',
|
||||
profile: {
|
||||
id: '#52Mathew',
|
||||
avatar: user1,
|
||||
name: 'David McMichael',
|
||||
time: '15 min ago '
|
||||
},
|
||||
data: {
|
||||
content: chance.paragraph({ sentences: 1 }),
|
||||
images: [],
|
||||
video: 'd1-FRj20WBE',
|
||||
likes: {
|
||||
like: true,
|
||||
value: 130
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// ==============================|| MOCK SERVICES ||============================== //
|
||||
|
||||
//mock.onGet('/api/posts/list').reply(200, { posts });
|
||||
mock.onGet('/api/posts/list').reply(() => {
|
||||
return [200, posts];
|
||||
});
|
||||
|
||||
mock.onPost('/api/posts/editComment').reply((config) => {
|
||||
try {
|
||||
const { key, id } = JSON.parse(config.data);
|
||||
|
||||
posts = posts.filter((post, index) => {
|
||||
if (post.id === key) {
|
||||
const cComments = post.data.comments || [];
|
||||
post.data.comments = [id, ...cComments];
|
||||
return post;
|
||||
}
|
||||
return post;
|
||||
});
|
||||
|
||||
return [200, { posts }];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [500, { message: 'Internal server error' }];
|
||||
}
|
||||
});
|
||||
|
||||
mock.onPost('/api/comments/add').reply((config) => {
|
||||
try {
|
||||
const { postId, comment } = JSON.parse(config.data);
|
||||
|
||||
const postIndex = posts.findIndex((x) => x.id === postId);
|
||||
const post = posts[postIndex];
|
||||
const cComments = post.data.comments || [];
|
||||
post.data.comments = [comment, ...cComments];
|
||||
|
||||
return [200, { posts: [...posts] }];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [500, { message: 'Internal server error' }];
|
||||
}
|
||||
});
|
||||
|
||||
mock.onPost('/api/replies/add').reply((config) => {
|
||||
try {
|
||||
const { postId, commentId, reply } = JSON.parse(config.data);
|
||||
const postIndex = posts.findIndex((x: any) => x.id === postId);
|
||||
const post = posts[postIndex];
|
||||
const cComments = post.data.comments || [];
|
||||
const commentIndex = cComments.findIndex((x: any) => x.id === commentId);
|
||||
const comment = cComments[commentIndex];
|
||||
/** comment.data.replies has to be defined */
|
||||
if (comment && comment.data && comment.data.replies) comment.data.replies = [...comment.data.replies, reply];
|
||||
return [200, { posts: [...posts] }];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [500, { message: 'Internal server error' }];
|
||||
}
|
||||
});
|
||||
|
||||
mock.onPost('/api/posts/list/like').reply((config) => {
|
||||
try {
|
||||
const { postId } = JSON.parse(config.data);
|
||||
const postIndex = posts.findIndex((x: any) => x.id === postId);
|
||||
|
||||
const post = { ...posts[postIndex] };
|
||||
post.data = { ...post.data };
|
||||
|
||||
post.data.likes = { ...post.data.likes };
|
||||
post.data.likes.like = !post.data.likes.like;
|
||||
post.data.likes.value = post.data.likes.like ? post.data.likes.value + 1 : post.data.likes.value - 1;
|
||||
posts[postIndex] = post;
|
||||
return [200, { posts: [...posts] }];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [500, { message: 'Internal server error' }];
|
||||
}
|
||||
});
|
||||
|
||||
mock.onPost('/api/comments/list/like').reply((config) => {
|
||||
try {
|
||||
const { postId, commentId } = JSON.parse(config.data);
|
||||
const postIndex = posts.findIndex((x: any) => x.id === postId);
|
||||
const post = posts[postIndex];
|
||||
const cComments = post.data.comments || [];
|
||||
const commentIndex = cComments.findIndex((x: any) => x.id === commentId);
|
||||
const comment = { ...cComments[commentIndex] };
|
||||
/** comment.data.likes has to be defined */
|
||||
if (comment && comment.data && comment.data.likes) comment.data.likes.like = !comment.data.likes.like;
|
||||
if (comment && comment.data && comment.data.likes)
|
||||
comment.data.likes.value = comment.data.likes.like ? comment.data.likes.value + 1 : comment.data.likes.value - 1;
|
||||
if (post && post.data && post.data.comments) post.data.comments[commentIndex] = comment;
|
||||
return [200, { posts: [...posts] }];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [500, { message: 'Internal server error' }];
|
||||
}
|
||||
});
|
||||
|
||||
mock.onPost('/api/replies/list/like').reply((config) => {
|
||||
try {
|
||||
const { postId, commentId, replayId } = JSON.parse(config.data);
|
||||
const postIndex = posts.findIndex((x: any) => x.id === postId);
|
||||
const post = posts[postIndex];
|
||||
const cComments = post.data.comments || [];
|
||||
const commentIndex = cComments.findIndex((x: any) => x.id === commentId);
|
||||
const comment = { ...cComments[commentIndex] };
|
||||
const replayIndex = comment?.data?.replies?.findIndex((x: any) => x.id === replayId);
|
||||
if (replayIndex !== undefined) {
|
||||
if (comment && comment.data && comment.data.replies) {
|
||||
const reply = { ...comment.data.replies[replayIndex] };
|
||||
if (reply && reply.data && reply.data.likes) {
|
||||
reply.data.likes.like = !reply.data.likes.like;
|
||||
reply.data.likes.value = reply.data.likes.like ? reply.data.likes.value + 1 : reply.data.likes.value - 1;
|
||||
}
|
||||
comment.data.replies[replayIndex] = reply;
|
||||
if (post && post.data && post.data.comments) post.data.comments[commentIndex] = comment;
|
||||
}
|
||||
}
|
||||
return [200, { posts: [...posts] }];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [500, { message: 'Internal server error' }];
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user