Skip to content

Commit

Permalink
fix: Change import statements in client.js to use capitalized class n…
Browse files Browse the repository at this point in the history
…ames.

- Import '@cocreate/crud-client' as Crud.
- Import '@cocreate/actions' as Action.
- Import '@cocreate/form' as Form.
- Import '@cocreate/render' as Render.
- Update references to lowercase variables crud, action, form, and render to use capitalized names Crud, Action, Form, and Render.
- Update function calls and accesses to crud to use Crud.
- Update function calls and accesses to form to use Form.
- Update function calls and accesses to render to use Render.
- Update function calls and accesses to crud.socket to use Crud.socket.
- Update function calls and accesses to crud.ObjectId() to use Crud.ObjectId().
- Update function calls and accesses to form.getData() to use Form.getData().
- Update function calls and accesses to form.setObjectId() to use Form.setObjectId().
- Update function calls and accesses to render.data() to use Render.data().
- Update function calls and accesses to crud.send() to use Crud.send().
- Update function calls and accesses to crud.socket.getSockets() to use Crud.socket.getSockets().
- Update function calls and accesses to crud.socket.serverOrganization to use Crud.socket.serverOrganization.
- Update function calls and accesses to crud.socket.config.organization_id to use Crud.socket.config.organization_id.
- Update function calls and accesses to crud.socket.config.key to use Crud.socket.config.key.
- Update function calls and accesses to crud.socket.config.host to use Crud.socket.config.host.
- Update function calls and accesses to crud.socket.config.user_id to use Crud.socket.config.user_id.
- Update function calls and accesses to crud.socket.clientId to use Crud.socket.clientId.

Summary:
- Capitalize import statements in client.js
- Update variable and function names to use capitalized names
  • Loading branch information
frankpagan committed Aug 5, 2023
1 parent efbf453 commit 912011b
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*globals CustomEvent, btoa*/
import crud from '@cocreate/crud-client';
import action from '@cocreate/actions';
import form from '@cocreate/form';
import render from '@cocreate/render';
import Crud from '@cocreate/crud-client';
import Action from '@cocreate/actions';
import Form from '@cocreate/form';
import Render from '@cocreate/render';
import '@cocreate/element-prototype';
import './index.css';
import localStorage from '@cocreate/local-storage';
Expand All @@ -15,15 +15,15 @@ const CoCreateUser = {

initSocket: function () {
const self = this;
crud.listen('updateUserStatus', (data) => self.updateUserStatus(data));
Crud.listen('updateUserStatus', (data) => self.updateUserStatus(data));
},

signUp: async function (btn) {
let formEl = btn.closest("form");
if (!formEl) return;

let organization_id = crud.socket.config.organization_id;
let array = form.getAttribute('array')
let organization_id = Crud.socket.config.organization_id;
let array = formEl.getAttribute('array')
if (!array) {
for (let el of formEl) {
array = el.getAttribute('array');
Expand All @@ -32,18 +32,18 @@ const CoCreateUser = {
}
}

let data = form.getData(formEl, array)
let data = Form.getData(formEl, array)
data.method = 'create.object'
data['array'] = array
data.organization_id = organization_id;

if (!data.object[0]._id)
data.object[0]._id = crud.ObjectId();
data.object[0]._id = Crud.ObjectId();

let user = await crud.send(data)
form.setObjectId(formEl, user)
let user = await Crud.send(data)
Form.setObjectId(formEl, user)

// const socket = crud.socket.getSockets()
// const socket = Crud.socket.getSockets()
// if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine) {
let key = {
method: 'create.object',
Expand All @@ -59,11 +59,11 @@ const CoCreateUser = {
organization_id
}

let response = await crud.send(key)
let response = await Crud.send(key)
if (response && response.object && response.object[0]) {
crud.socket.send({ method: 'signUp', user, userKey })
Crud.socket.send({ method: 'signUp', user, userKey })

render.data({
Render.data({
selector: "[template='signUp']",
data: {
type: 'signUp',
Expand Down Expand Up @@ -102,9 +102,9 @@ const CoCreateUser = {
}
}

const socket = crud.socket.getSockets()
if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine || crud.socket.serverOrganization == false) {
crud.send(request).then((response) => {
const socket = Crud.socket.getSockets()
if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine || Crud.socket.serverOrganization == false) {
Crud.send(request).then((response) => {
response['success'] = false
response['status'] = "signIn failed"
if (response.object && response.object[0]) {
Expand All @@ -120,7 +120,7 @@ const CoCreateUser = {
request.method = 'signIn'
request.broadcastBrowser = false
delete request.storage
crud.socket.send(request).then((response) => {
Crud.socket.send(request).then((response) => {
this.signInResponse(response)
})
}
Expand All @@ -130,9 +130,9 @@ const CoCreateUser = {
let { success, status, message, user_id, token } = data;

if (success) {
localStorage.setItem('organization_id', crud.socket.config.organization_id);
localStorage.setItem("key", crud.socket.config.key);
localStorage.setItem("host", crud.socket.config.host);
localStorage.setItem('organization_id', Crud.socket.config.organization_id);
localStorage.setItem("key", Crud.socket.config.key);
localStorage.setItem("host", Crud.socket.config.host);
localStorage.setItem('user_id', user_id);
localStorage.setItem("token", token);
// document.cookie = `token=${token};path=/`;
Expand All @@ -144,7 +144,7 @@ const CoCreateUser = {
else
message = "The email or password you entered is incorrect";

render.data({
Render.data({
selector: "[template='signIn']",
data: {
type: 'signIn',
Expand All @@ -166,7 +166,7 @@ const CoCreateUser = {
// document.cookie = allCookies[i] + "=;expires=" +
// new Date(0).toUTCString();

render.data({
Render.data({
selector: "[template='signOut']",
data: {
type: 'signOut',
Expand All @@ -192,9 +192,9 @@ const CoCreateUser = {
},

redirect: (data) => {
if (data.user_id && data.user_id !== crud.socket.config.user_id)
if (data.user_id && data.user_id !== Crud.socket.config.user_id)
return
if (!data.user_id && data.clientId !== crud.socket.clientId)
if (!data.user_id && data.clientId !== Crud.socket.clientId)
return
if (data.userStatus == 'on' || data.userStatus == 'idle') {
let redirectTag = document.querySelector('[session="true"]');
Expand Down Expand Up @@ -226,7 +226,7 @@ const CoCreateUser = {
let redirectTag = document.querySelector('[session]');

if (redirectTag) {
crud.socket.send({
Crud.socket.send({
method: 'sendMessage',
message: 'checkSession',
broadcast: false,
Expand All @@ -244,23 +244,23 @@ const CoCreateUser = {
};


action.init({
Action.init({
name: "signUp",
endEvent: "signUp",
callback: (data) => {
CoCreateUser.signUp(data.element);
},
});

action.init({
Action.init({
name: "signIn",
endEvent: "signIn",
callback: (data) => {
CoCreateUser.signIn(data.element);
},
});

action.init({
Action.init({
name: "signOut",
endEvent: "signOut",
callback: (data) => {
Expand Down

0 comments on commit 912011b

Please sign in to comment.