modify(mock-data): Added env check to mock data injections

This commit is contained in:
Taso committed 2020-12-11 12:38:08 -05:00
1 parent 093af64c46
commit e13b064d73
1 file changed
+179 -177
+179 -177
View File
@@ -25,196 +25,198 @@ import { useNotesService } from "./apps/notes/hooks/useNotesService";
import { usePhotoService } from "./apps/camera/hooks/usePhotoService"; import { usePhotoService } from "./apps/camera/hooks/usePhotoService";
import Nui from "./os/nui-events/utils/Nui"; import Nui from "./os/nui-events/utils/Nui";
//These events are just for testing. Comment it out before building. // Inject mock data when in development env.
setTimeout(() => { if (process.env.NODE_ENV === 'development') {
window.dispatchEvent( setTimeout(() => {
new MessageEvent("message", { window.dispatchEvent(
data: { new MessageEvent("message", {
app: "CAMERA", data: {
method: "setPhotos", app: "CAMERA",
data: [ method: "setPhotos",
{ data: [
id: 1, {
image: 'https://i.imgur.com/OO8wx6Z.jpg', id: 1,
}, image: 'https://i.imgur.com/OO8wx6Z.jpg',
{ },
id: 1, {
image: 'https://i.imgur.com/pqGBiST.jpg' id: 1,
} image: 'https://i.imgur.com/pqGBiST.jpg'
], }
}, ],
}) },
); })
}, 1000); );
}, 1000);
setTimeout(() => { setTimeout(() => {
window.dispatchEvent( window.dispatchEvent(
new MessageEvent("message", { new MessageEvent("message", {
data: { data: {
app: "SIMCARD", app: "SIMCARD",
method: "setNumber", method: "setNumber",
data: "111-1134", data: "111-1134",
}, },
}) })
); );
}, 1000); }, 1000);
setTimeout(() => { setTimeout(() => {
window.dispatchEvent( window.dispatchEvent(
new MessageEvent("message", { new MessageEvent("message", {
data: { data: {
app: "PHONE", app: "PHONE",
method: "setVisibility", method: "setVisibility",
data: true, data: true,
}, },
}) })
); );
}, 1000); }, 1000);
setTimeout(() => { setTimeout(() => {
window.dispatchEvent( window.dispatchEvent(
new MessageEvent("message", { new MessageEvent("message", {
data: { data: {
app: 'NOTES', app: 'NOTES',
method: 'setNotes', method: 'setNotes',
data: [ data: [
{ {
id: 1, id: 1,
title: 'First note', title: 'First note',
content: 'Hello, this is my shitty note' content: 'Hello, this is my shitty note'
}, },
{ {
id: 2, id: 2,
title: 'Second note', title: 'Second note',
content: 'Hello, this is another shitty note' content: 'Hello, this is another shitty note'
}, },
] ]
} }
}) })
) )
}, 1000) }, 1000)
setTimeout(() => { setTimeout(() => {
new MessageEvent("messsage", { new MessageEvent("messsage", {
data: {
app: "BANK",
method: "setNotification",
data: {
id: 1,
message: "ahhaha"
}
}
})
}, 1000)
setTimeout(() => {
new MessageEvent("messsage", {
data: {
app: "TWITTER",
method: "setNotification",
data: {
id: 1,
message: "ahhaha"
}
}
})
}, 1000)
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: { data: {
app: "BANK", app: "BANK",
method: "setCredentials", method: "setNotification",
data: data: {
{ id: 1,
name: "Firstname Lastname", message: "ahhaha"
balance: 2000 }
}
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
app: 'BANK',
method: 'setTransaction',
data: [
{
id: 1,
amount: 200,
type: 'Deposit',
source: "chip"
},{
id: 2,
amount: 200,
type: 'Withdraw',
source: "chip"
},
{
id: 3,
amount: 200,
type: 'Withdraw',
source: "chip"
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: "chip"
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: "chip"
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: "chip"
}
]
} }
}) })
) }, 1000)
}, 1000)
setTimeout(() => { setTimeout(() => {
window.dispatchEvent( new MessageEvent("messsage", {
new MessageEvent("message", {
data: { data: {
app: "SELLOUT", app: "TWITTER",
method: "setListings", method: "setNotification",
data: [ data: {
{ id: 1,
id: 1, message: "ahhaha"
name: "Some guy", }
number: "123-4567", }
title: "Car",
description:
"Selling this cool car",
url: "https://i.imgur.com/ROmGTwi.jpeg",
},
{
id: 2,
name: "Some other dude",
number: "666-6666",
title: "Material",
description: "Selling my wife",
url: "",
},
],
},
}) })
); }, 1000)
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
app: "BANK",
method: "setCredentials",
data:
{
name: "Firstname Lastname",
balance: 2000
}
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
app: 'BANK',
method: 'setTransaction',
data: [
{
id: 1,
amount: 200,
type: 'Deposit',
source: "chip"
},{
id: 2,
amount: 200,
type: 'Withdraw',
source: "chip"
},
{
id: 3,
amount: 200,
type: 'Withdraw',
source: "chip"
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: "chip"
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: "chip"
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: "chip"
}
]
}
})
)
}, 1000)
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
app: "SELLOUT",
method: "setListings",
data: [
{
id: 1,
name: "Some guy",
number: "123-4567",
title: "Car",
description:
"Selling this cool car",
url: "https://i.imgur.com/ROmGTwi.jpeg",
},
{
id: 2,
name: "Some other dude",
number: "666-6666",
title: "Material",
description: "Selling my wife",
url: "",
},
],
},
})
);
}, 1000);
}
function Phone() { function Phone() {
useNuiService(); useNuiService();