Skip to content

Commit 90853ff

Browse files
Merge pull request #74 from SupportVol/deepsource-transform-e784c303
style: format code with Prettier and StandardJS
2 parents b0eee12 + c773bf0 commit 90853ff

File tree

4 files changed

+113
-113
lines changed

4 files changed

+113
-113
lines changed
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import randomImageGenerator from "../../utils/helper/randomImageGenerator.js";
1+
import randomImageGenerator from '../../utils/helper/randomImageGenerator.js'
22
/**
33
* Retrieves the profile picture URL for the current user and sends a JSON response.
44
* @param {Object} req - The request object.
55
* @param {Object} res - The response object.
66
* @returns {Object} - JSON response with the user's profile picture URL.
77
*/
88
const getProfilePicture = async (req, res) => {
9-
const { auth, storage, uid } = req;
10-
let url = NaN;
11-
url = await storage.getDownloadURL(`pfp/${uid}`);
9+
const { auth, storage, uid } = req
10+
let url = NaN
11+
url = await storage.getDownloadURL(`pfp/${uid}`)
1212
if (url[0] === false) {
13-
url = await auth.getUser(uid);
13+
url = await auth.getUser(uid)
1414
}
1515
return res.json({
16-
response: url[1],
17-
});
18-
};
16+
response: url[1]
17+
})
18+
}
1919

2020
/**
2121
* Uploads a new profile picture for the current user and updates the user's photo URL in the database.
@@ -25,17 +25,17 @@ const getProfilePicture = async (req, res) => {
2525
*/
2626

2727
const uploadProfilePicture = async (req, res) => {
28-
const { body, storage, auth, uid } = req;
29-
let { imageBase64, reqUrl } = body;
28+
const { body, storage, auth, uid } = req
29+
let { imageBase64, reqUrl } = body
3030
if (imageBase64) {
31-
const response = storage.uploadByte8Array(path, imageBase64);
32-
reqUrl = response[response.length - 1];
31+
const response = storage.uploadByte8Array(path, imageBase64)
32+
reqUrl = response[response.length - 1]
3333
}
34-
reqUrl = await auth.updateUser(uid, { photoURL: reqUrl });
34+
reqUrl = await auth.updateUser(uid, { photoURL: reqUrl })
3535
return res.json({
36-
response: reqUrl[1].photoURL,
37-
});
38-
};
36+
response: reqUrl[1].photoURL
37+
})
38+
}
3939

4040
/**
4141
* Deletes the profile picture for the current user and updates the user's photo URL in the database to NaN.
@@ -44,17 +44,17 @@ const uploadProfilePicture = async (req, res) => {
4444
* @returns {Object} - JSON response with the profile picture deletion status.
4545
*/
4646
const deleteProfilePicture = async (req, res) => {
47-
const { storage, auth, uid } = req;
48-
let del = NaN;
49-
del = await storage.deleteFile(`pfp/${uid}`);
47+
const { storage, auth, uid } = req
48+
let del = NaN
49+
del = await storage.deleteFile(`pfp/${uid}`)
5050
if (del[0] === false) {
51-
del = await auth.updateUser(uid, { photoURL: randomImageGenerator() });
51+
del = await auth.updateUser(uid, { photoURL: randomImageGenerator() })
5252
}
5353
// "https://www.pngfind.com/pngs/m/676-6764065_default-profile-picture-transparent-hd-png-download.png"
5454
return res.json({
55-
response: "User was Deleted",
56-
});
57-
};
55+
response: 'User was Deleted'
56+
})
57+
}
5858

59-
export { getProfilePicture, uploadProfilePicture, deleteProfilePicture };
60-
randomImageGenerator;
59+
export { getProfilePicture, uploadProfilePicture, deleteProfilePicture }
60+
randomImageGenerator

models/community/InitiativeModel.js

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Importing necessary modules
2-
import Firestore from "../../firebaseCP/firestore.js";
3-
import updateData from "../../utils/firestore/updateData.js";
4-
import EndeavorEntity from "./EndeavorEntity.js";
5-
import { admin } from "../../config/firebase.js";
2+
import Firestore from '../../firebaseCP/firestore.js'
3+
import updateData from '../../utils/firestore/updateData.js'
4+
import EndeavorEntity from './EndeavorEntity.js'
5+
import { admin } from '../../config/firebase.js'
66

77
/**
88
* Class representing an Initiative.
@@ -18,7 +18,7 @@ export default class Initiative extends EndeavorEntity {
1818
* @param {string} introductory_video_URL - The URL of the introductory video.
1919
* @param {Array} projects - The projects of the initiative.
2020
*/
21-
constructor(
21+
constructor (
2222
name,
2323
organizations,
2424
volunteers,
@@ -46,28 +46,28 @@ export default class Initiative extends EndeavorEntity {
4646
introductory_video_URL,
4747
projects,
4848
communityUID
49-
);
50-
this.name = name;
51-
this.organizations = organizations;
52-
this.volunteers = volunteers;
53-
this.started_date = started_date;
54-
this.expected_completing_date = expected_completing_date;
55-
this.initiated_organization = initiated_organization;
56-
this.slogun = slogun;
57-
this.mission = mission;
58-
this.objectives = objectives;
59-
this.introductory_video_URL = introductory_video_URL;
60-
this.projects = projects;
61-
this.communityUID = communityUID;
62-
this.initiativeUID = initiativeUID;
63-
this.fs = new Firestore(this.collectionName, this.initiativeID, []);
49+
)
50+
this.name = name
51+
this.organizations = organizations
52+
this.volunteers = volunteers
53+
this.started_date = started_date
54+
this.expected_completing_date = expected_completing_date
55+
this.initiated_organization = initiated_organization
56+
this.slogun = slogun
57+
this.mission = mission
58+
this.objectives = objectives
59+
this.introductory_video_URL = introductory_video_URL
60+
this.projects = projects
61+
this.communityUID = communityUID
62+
this.initiativeUID = initiativeUID
63+
this.fs = new Firestore(this.collectionName, this.initiativeID, [])
6464
}
6565

6666
/**
6767
* Create a new initiative.
6868
* @return {Promise} A promise that resolves with the created initiative.
6969
*/
70-
create() {
70+
create () {
7171
const initiativeData = {
7272
name: this.name,
7373
organizations: this.organizations,
@@ -80,31 +80,31 @@ export default class Initiative extends EndeavorEntity {
8080
objectives: this.objectives,
8181
introductory_video_URL: this.introductory_video_URL,
8282
projects: this.projects,
83-
communityUID: this.communityUID,
84-
};
85-
return this.fs.create(initiativeData);
83+
communityUID: this.communityUID
84+
}
85+
return this.fs.create(initiativeData)
8686
}
8787

8888
/**
8989
* Update an existing initiative.
9090
* @return {Promise} A promise that resolves with the updated initiative.
9191
*/
92-
update() {
93-
const record = this.read();
92+
update () {
93+
const record = this.read()
9494
const updatedData = updateData(
9595
[
96-
"name",
97-
"organizations",
98-
"volunteers",
99-
"started_date",
100-
"expected_completing_date",
101-
"initiated_organization",
102-
"slogun",
103-
"mission",
104-
"objectives",
105-
"introductory_video_URL",
106-
"projects",
107-
"communityUID",
96+
'name',
97+
'organizations',
98+
'volunteers',
99+
'started_date',
100+
'expected_completing_date',
101+
'initiated_organization',
102+
'slogun',
103+
'mission',
104+
'objectives',
105+
'introductory_video_URL',
106+
'projects',
107+
'communityUID'
108108
],
109109
[
110110
this.name,
@@ -118,10 +118,10 @@ export default class Initiative extends EndeavorEntity {
118118
this.objectives,
119119
this.introductory_video_URL,
120120
this.projects,
121-
this.communityUID,
121+
this.communityUID
122122
],
123123
record
124-
);
125-
return this.fs.update(updatedData);
124+
)
125+
return this.fs.update(updatedData)
126126
}
127127
}
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Authentication } from "../../firebaseCP/authentication.js";
2-
import Firestore from "../../firebaseCP/firestore.js";
3-
import FirestoreAbstract from "../../utils/firestore/FirestoreAbstract.js";
4-
import updateData from "../../utils/firestore/updateData.js";
1+
import { Authentication } from '../../firebaseCP/authentication.js'
2+
import Firestore from '../../firebaseCP/firestore.js'
3+
import FirestoreAbstract from '../../utils/firestore/FirestoreAbstract.js'
4+
import updateData from '../../utils/firestore/updateData.js'
55

66
export default class MembershipRequestModel extends FirestoreAbstract {
7-
constructor(
7+
constructor (
88
registrationCertificateUrl,
99
annualReportUrl,
1010
legalDocumentsUrl,
@@ -14,7 +14,7 @@ export default class MembershipRequestModel extends FirestoreAbstract {
1414
description,
1515
requestID = false
1616
) {
17-
super();
17+
super()
1818
this.createStructure = {
1919
name,
2020
description,
@@ -23,21 +23,21 @@ export default class MembershipRequestModel extends FirestoreAbstract {
2323
registrationCertificateUrl,
2424
annualReportUrl,
2525
legalDocumentsUrl,
26-
creationDate: Date.now(),
27-
};
28-
this.fs = new Firestore("organizationsRequests", this.requestID);
29-
const currentRecord = this.read();
26+
creationDate: Date.now()
27+
}
28+
this.fs = new Firestore('organizationsRequests', this.requestID)
29+
const currentRecord = this.read()
3030
this.updateStructure = updateData(
3131
[
32-
"name",
33-
"description",
34-
"email",
35-
"password",
36-
"registrationCertificateUrl",
37-
"annualReportUrl",
38-
"legalDocumentsUrl",
39-
"creationDate",
40-
"accepted",
32+
'name',
33+
'description',
34+
'email',
35+
'password',
36+
'registrationCertificateUrl',
37+
'annualReportUrl',
38+
'legalDocumentsUrl',
39+
'creationDate',
40+
'accepted'
4141
],
4242
[
4343
name,
@@ -48,31 +48,31 @@ export default class MembershipRequestModel extends FirestoreAbstract {
4848
annualReportUrl,
4949
legalDocumentsUrl,
5050
Date.now(),
51-
false,
51+
false
5252
],
5353
currentRecord
54-
);
55-
this.requestID = requestID;
54+
)
55+
this.requestID = requestID
5656
}
5757

58-
approve() {
59-
const record = this.fs.read();
60-
this.fs.delete();
61-
this.fs = new Firestore("organizations", this.requestID);
62-
const orgID = this.fs.create(record)[1];
63-
this.auth = new Authentication();
64-
this.auth.createUser({ email: record.email, password: record.password });
65-
this.authFS = new Firestore("users", orgID);
58+
approve () {
59+
const record = this.fs.read()
60+
this.fs.delete()
61+
this.fs = new Firestore('organizations', this.requestID)
62+
const orgID = this.fs.create(record)[1]
63+
this.auth = new Authentication()
64+
this.auth.createUser({ email: record.email, password: record.password })
65+
this.authFS = new Firestore('users', orgID)
6666
this.authFS.create({
6767
orgID,
68-
role: "Organization",
69-
level: 0,
70-
});
71-
return orgID;
68+
role: 'Organization',
69+
level: 0
70+
})
71+
return orgID
7272
}
7373

74-
decline() {
75-
this.fs.delete();
76-
return true;
74+
decline () {
75+
this.fs.delete()
76+
return true
7777
}
7878
}

utils/firestore/updateData.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import isArray from "../validation/isArray.js";
1+
import isArray from '../validation/isArray.js'
22

33
const updateData = (fields, data, alreadyData) => {
4-
const updateStructure = {};
4+
const updateStructure = {}
55
fields.forEach((field, index) => {
6-
console.log(updateStructure);
6+
console.log(updateStructure)
77
if (Array.isArray(alreadyData[field])) {
8-
updateStructure[field] = isArray(data[index], alreadyData[field]);
8+
updateStructure[field] = isArray(data[index], alreadyData[field])
99
}
10-
updateStructure[field] = data[index] ?? alreadyData[field];
11-
console.log(updateStructure);
12-
});
13-
return updateStructure;
14-
};
15-
export default updateData;
10+
updateStructure[field] = data[index] ?? alreadyData[field]
11+
console.log(updateStructure)
12+
})
13+
return updateStructure
14+
}
15+
export default updateData

0 commit comments

Comments
 (0)