Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
261 commits
Select commit Hold shift + click to select a range
e506655
some more minor changes
Leekao Aug 14, 2018
9374e7d
improve performance. and add stats. remove jquery,loadsh,steps, joyride
Aminadav Aug 14, 2018
4b6c701
remove rtlss
Aminadav Aug 14, 2018
443a9b1
fix build process
Aminadav Aug 14, 2018
c62b3eb
fix build
Aminadav Aug 14, 2018
0a0ea0c
[B] commented out notification on txId
Leekao Aug 14, 2018
4230052
mid-commit, search still clunky
Leekao Aug 14, 2018
19702ae
Revert "mid-commit, search still clunky"
Leekao Aug 14, 2018
2070092
Merge remote-tracking branch 'origin/erez' into production
Aminadav Aug 14, 2018
f43c0f4
Merge remote-tracking branch 'origin/production' into search_bar
Leekao Aug 15, 2018
0b53986
[B] wierd bug
Leekao Aug 15, 2018
fc26f72
Merge branch 'erez' into production
Aminadav Aug 15, 2018
e0525ac
fix async await. merge from erez
Aminadav Aug 15, 2018
9a05ddd
[B] removed url from forgot-email
Leekao Aug 15, 2018
21ca615
[F] logout now clears login/signup forms
Leekao Aug 15, 2018
8ed5235
[F] some text changes
Leekao Aug 15, 2018
158767c
new ajax loaders
Aminadav Aug 15, 2018
4ae552f
Merge remote-tracking branch 'origin/production' into erez
Leekao Aug 15, 2018
1e92df6
[F] ajax-loader added to csvUpload
Leekao Aug 15, 2018
bc2c6b2
add design to inlinemanual. and script for share
Aminadav Aug 15, 2018
ed4a1d4
fix balance box
Aminadav Aug 15, 2018
c393729
make inlinemanual scss important
Aminadav Aug 15, 2018
bb38cd0
[F] removes lead_price tag from myLeads, added svgs so we can remove fa
Leekao Aug 15, 2018
76db56c
[F] added svgs that were left out of last commit by mistake
Leekao Aug 15, 2018
d30c9c9
[F] more svgs
Leekao Aug 15, 2018
a87d9a6
[F] notifications now load onLoad and only display last 5
Leekao Aug 15, 2018
453dcf7
[F] amended last commit
Leekao Aug 15, 2018
d12d3b1
[F] fixed broken commit
Leekao Aug 15, 2018
022aa96
[F] removed buy button [B] removed contact info from leads not bought
Leekao Aug 15, 2018
2c73931
mid-commit, working on display-lead page
Leekao Aug 15, 2018
7c92fec
added displayLead page
Leekao Aug 16, 2018
260ca79
[F] fixed broken commit cuz of missing svg
Leekao Aug 16, 2018
55bcf7e
[F] moved home down
Leekao Aug 16, 2018
55758da
[F] added scss that failed last commit, added more dots
Leekao Aug 16, 2018
1568482
fix withInfiniteScroll hoc
meirkoen Aug 16, 2018
5de7878
set fullyLoaded true if result length less then limit
meirkoen Aug 16, 2018
ac98246
Merge remote-tracking branch 'origin/noam' into erez
Leekao Aug 19, 2018
3586839
[B] fixed user signup error strings, [F] signup now sends fname,lname…
Leekao Aug 19, 2018
ee78aae
Merge remote-tracking branch 'origin/production' into noam
noamsilver Aug 19, 2018
50fe052
Merge remote-tracking branch 'origin/erez' into noam
noamsilver Aug 19, 2018
0cf54dd
Merge remote-tracking branch 'origin/noam' into erez
Leekao Aug 19, 2018
bca29e9
fixed error msgs display on signUp
Leekao Aug 19, 2018
4a32034
fix header demo and balance
meirkoen Aug 19, 2018
2f7436a
added move to uploadCSV
noamsilver Aug 19, 2018
9b49d42
Merge pull request #8 from LeadcoinNetwork/scroll
alice-613 Aug 19, 2018
8d52849
Merge branch 'production' into balance-mobile
alice-613 Aug 19, 2018
a42c1bd
Merge pull request #9 from LeadcoinNetwork/balance-mobile
alice-613 Aug 19, 2018
9618dca
Merge pull request #10 from LeadcoinNetwork/erez
alice-613 Aug 19, 2018
7574abb
Merge branch 'production' into noam
alice-613 Aug 19, 2018
1b4b5e6
Merge pull request #11 from LeadcoinNetwork/noam
alice-613 Aug 19, 2018
cecd0b1
[F] displayLead now displays without route
Leekao Aug 20, 2018
7b27d24
[F] changed ajax/submit in CsvUpload
Leekao Aug 20, 2018
442b8cb
[F] notifications now removed from state when loggedOut
Leekao Aug 20, 2018
aa2783f
[F] added loading to button properly
Leekao Aug 20, 2018
14bc279
[F] sidebar icons now vanish when mobile/tablet
Leekao Aug 20, 2018
de2efb7
loading dots - show with opacity
meirkoen Aug 20, 2018
65fc5bc
hide loading dots if fully loaded
meirkoen Aug 20, 2018
7f2845b
[F] changed css of icons to be smaller
Leekao Aug 20, 2018
bc3276b
[F] changed look of notification, [B] changed notification text
Leekao Aug 20, 2018
deb603e
[F] some small css changed to notification, to look better
Leekao Aug 20, 2018
a1f143a
home - one icon
meirkoen Aug 20, 2018
c43942d
home -2 icons
meirkoen Aug 20, 2018
c2dc120
[F] amended last commit, submit/loading
Leekao Aug 20, 2018
f0f1303
change tsconfig, add node_modules to exclue
Aminadav Aug 21, 2018
d281399
Merge remote-tracking branch 'origin/loading-dots' into production
Aminadav Aug 21, 2018
6efcc4f
disable chrome password save popup
Aminadav Aug 21, 2018
608aed6
Merge remote-tracking branch 'origin/erez' into production
Aminadav Aug 21, 2018
8bb5a67
remove nav icons in tablet view
noamsilver Aug 21, 2018
6d9fedd
add etherscan tx to inline manual
Aminadav Aug 21, 2018
cf9e31b
fix twitter text
Aminadav Aug 21, 2018
d56dfe6
fix inlinnemanual twitter text
Aminadav Aug 21, 2018
2906276
Merge branch 'production' into noam
noamsilver Aug 21, 2018
7bc3a77
fix inifintescroll
Aminadav Aug 21, 2018
3e730cf
Merge branch 'production' into home-gui
meirkoen Aug 21, 2018
74cfb40
home - icons for desktop and for mobile + gui fixes
meirkoen Aug 21, 2018
2bd3975
buttons style
meirkoen Aug 21, 2018
682a893
new style for selects
meirkoen Aug 21, 2018
fe9bcb8
text fields new style
meirkoen Aug 21, 2018
85148ea
add lead Checkbox
meirkoen Aug 21, 2018
b9494b1
remove renderFilters
meirkoen Aug 21, 2018
1ce74ce
buy leads button position
meirkoen Aug 21, 2018
3f6a6bf
add seperator
meirkoen Aug 21, 2018
1e7f90a
padding fix
meirkoen Aug 21, 2018
035305a
add search results title
meirkoen Aug 21, 2018
ecbd2b0
buy leads - mobile
meirkoen Aug 21, 2018
1cbcbb4
initial cards view
noamsilver Aug 21, 2018
9c95981
Merge remote-tracking branch 'origin/erez' into search_bar
Leekao Aug 22, 2018
c9772d8
added some untracked files
Leekao Aug 22, 2018
ab9b8be
Merge branch 'noam' of https://github.com/LeadcoinNetwork/Web-App-Pro…
meirkoen Aug 22, 2018
a6b48e6
merge with noam
meirkoen Aug 22, 2018
0fbc022
[F] mobile css for snackbar alert and displayLead page
Leekao Aug 22, 2018
482004e
render buy button inside renderResultsHead
meirkoen Aug 22, 2018
b13482b
buy leads page - desktop fixes
meirkoen Aug 22, 2018
36623a3
remove select all from cards
meirkoen Aug 22, 2018
183239b
minor
meirkoen Aug 22, 2018
9d10216
[F] fixed mobile css on CsvUpload
Leekao Aug 22, 2018
6175229
remove table head on zero results
meirkoen Aug 22, 2018
7a25def
add sell zeroResults message
meirkoen Aug 22, 2018
debb43a
remove log
meirkoen Aug 22, 2018
6380111
buy leads - mobile fixes
meirkoen Aug 22, 2018
115039b
remove log
meirkoen Aug 22, 2018
d33d768
[F] addLead on mobile
Leekao Aug 22, 2018
ae991c8
tmp
noamsilver Aug 22, 2018
4a9386f
Merge remote-tracking branch 'origin/home-gui' into gui
Aminadav Aug 22, 2018
1069a64
hide switch to cards
meirkoen Aug 22, 2018
1f34552
[F] changed the template csv file to hold real data
Leekao Aug 22, 2018
2eb59c7
Merge branch 'gui' of https://github.com/LeadcoinNetwork/Web-App-Proj…
Aminadav Aug 22, 2018
0b6d333
fix inlinemanual scss.
Aminadav Aug 22, 2018
2bf75e3
Merge remote-tracking branch 'origin/production' into erez
Leekao Aug 22, 2018
b76b33e
[F] long txId no longer fucks with the snackbar alert
Leekao Aug 22, 2018
62d8717
[F] snackbar close button now shows in mobile
Leekao Aug 22, 2018
2507c89
several small eyal fixes, text, and asterik
Aminadav Aug 22, 2018
58f6223
[F] changed test in CsvUpload
Leekao Aug 22, 2018
84d95fe
add google drive image
Aminadav Aug 22, 2018
146b414
reverted quote back to fake one
Leekao Aug 22, 2018
ddd62ab
Merge remote-tracking branch 'origin/production' into erez
Leekao Aug 22, 2018
e0d30ed
merge from gui
noamsilver Aug 22, 2018
01b284e
merge with production
noamsilver Aug 22, 2018
196b10f
notification mobile
meirkoen Aug 22, 2018
a768dd1
close button for notification inner
meirkoen Aug 23, 2018
e901036
[B] buyLeads no longer displays leads owned by self
Leekao Aug 23, 2018
12929bc
fix short email on user menu
meirkoen Aug 23, 2018
edf0151
removed experimental code
noamsilver Aug 23, 2018
b61ec0d
in mobile show only cards view
noamsilver Aug 23, 2018
6d22c0d
Merge branch 'production' into notification-mobile
Aminadav Aug 23, 2018
0916358
[F] added titles to csvUpload
Leekao Aug 23, 2018
7d574ab
[F] added back the labels to addLead and made some small css adjustme…
Leekao Aug 23, 2018
dc34f69
Merge remote-tracking branch 'origin/production' into erez
Leekao Aug 23, 2018
3ed7a66
sepereate leads button on mobile
Aminadav Aug 23, 2018
08008a3
Merge branch 'erez' into noam
noamsilver Aug 23, 2018
83c787a
show search results title only on buy page, remove results count,
noamsilver Aug 23, 2018
c04b74b
remove the $ sign from cards when no lead price available
noamsilver Aug 23, 2018
0c84b2d
Merge remote-tracking branch 'origin/noam' into production
Aminadav Aug 26, 2018
25860dc
inlinemanual: fix save dialog step on desktop scss
Aminadav Aug 26, 2018
3234e1b
inlinemanual: push email to google forms on finish
Aminadav Aug 26, 2018
25e7155
add google analytics
Aminadav Aug 26, 2018
9a4b084
puppets mid-commit
Leekao Aug 26, 2018
4b5f0a6
Merge remote-tracking branch 'origin/noam' into erez
Leekao Aug 26, 2018
d19f56e
start work on open/close cards
noamsilver Aug 26, 2018
090a1a6
[B] date now properly set when adding lead using the form
Leekao Aug 26, 2018
a6570c0
add google analytics. fix login scss remember me
Aminadav Aug 26, 2018
b611214
remvoed slides from repo
Leekao Aug 26, 2018
7b7d90c
[P] continued working on puppet
Leekao Aug 26, 2018
28179a7
[F] floating buy button at bottom cuz why not?
Leekao Aug 26, 2018
1f1c3d1
card selction
noamsilver Aug 26, 2018
a75cc02
[F] fixed the loading_dots position on mobile
Leekao Aug 26, 2018
1745f2c
[P] puppet now finishes the buying part of the inline-manual
Leekao Aug 26, 2018
9e00eb4
arrow open/close
noamsilver Aug 27, 2018
033d8d8
[F] moved loading dots to center
Leekao Aug 27, 2018
9bd6406
fixed dots centring
noamsilver Aug 27, 2018
7892d99
Merge branch 'erez' into noam
noamsilver Aug 27, 2018
fc1db0e
fixes to arrow positioning
noamsilver Aug 27, 2018
05be310
[P] puppet finishes inline-manual successfully
Leekao Aug 27, 2018
1699c3d
[P] split puppets to web & mobile
Leekao Aug 27, 2018
d962e35
variable cards content
noamsilver Aug 27, 2018
c23ea27
Merge remote-tracking branch 'origin/noam' into erez
Leekao Aug 27, 2018
fd0cf34
[P] mobile puppet finishes inline-manual
Leekao Aug 27, 2018
d74c261
[P] cleaning up a bit
Leekao Aug 27, 2018
5d52dad
Merge branch 'production' into noam
noamsilver Aug 27, 2018
6629ac0
[P] puppets now run in parallel
Leekao Aug 27, 2018
90973af
added translation support and fixed date display in cards
noamsilver Aug 27, 2018
2e35773
[P] working on loading env
Leekao Aug 27, 2018
1381d4f
minimal fields in shopping cart
noamsilver Aug 27, 2018
4cef71b
[P] Puppets read settings from env (file or global)
Leekao Aug 27, 2018
ea8fd3f
[P] minor changes
Leekao Aug 27, 2018
9b59014
added table variables
noamsilver Aug 28, 2018
a306afa
new shopping cart table
noamsilver Aug 28, 2018
cba170e
add option to show all details to cards constantly
noamsilver Aug 28, 2018
bd1a74a
Merge branch 'new-checkout' into noam
noamsilver Aug 28, 2018
007c545
arrow position fix
noamsilver Aug 28, 2018
20f9a23
changed names and no change to cursor when constant cards view
noamsilver Aug 28, 2018
a06b18c
fixed class name
noamsilver Aug 28, 2018
6bdf0cc
add cursor pointer to add to selection button
noamsilver Aug 28, 2018
9694320
[P] removed annoying comment
Leekao Aug 28, 2018
1bbafcb
Merge remote-tracking branch 'origin/noam' into erez
Leekao Aug 28, 2018
2aab594
fix storybook
Aminadav Aug 28, 2018
3831ffe
Merge remote-tracking branch 'origin/noam' into production
Aminadav Aug 28, 2018
7f5f0d3
Merge remote-tracking branch 'origin/erez' into production
Aminadav Aug 28, 2018
b7e65b5
[P] tinkered with the web puppet trying to optimize it
Leekao Aug 28, 2018
cc7196a
[P] now works as server and using same chrome process to launch 2 inc…
Leekao Aug 28, 2018
750db2c
[P] puppets no longer check balance
Leekao Aug 29, 2018
2af058f
Merge remote-tracking branch 'origin/production' into erez
Leekao Aug 29, 2018
d20d6ea
[P] no more waiting fixed number of seconds, now we only wait for net…
Leekao Aug 29, 2018
2690f17
[F] changed testemonials
Leekao Aug 30, 2018
4c00d7c
[F] fixed typo in testemonial
Leekao Aug 30, 2018
77ca2d3
[F] another typo
Leekao Aug 30, 2018
f1b3e56
static images for LP
noam-leadcoin Aug 30, 2018
18eda85
removed .env and added .env.example instead
Leekao Aug 30, 2018
b343552
[P] puppets do not use incog because they use seperate profiles
Leekao Aug 30, 2018
98a37ee
[B] added mysql.escapes where needed
Leekao Aug 30, 2018
f45b98a
[P] refactored puppets to run either on server or single run mode, ad…
Leekao Sep 1, 2018
c831ee8
[P] made the web api a bit prettier and more comefortable
Leekao Sep 1, 2018
723bdc4
[P] single run no longer take pictures, next run time is displayed
Leekao Sep 2, 2018
ed5ac6f
[P] puppets now use Puppetstein as last name, also use email from pup…
Leekao Sep 2, 2018
7f250b1
Merge remote-tracking branch 'origin/erez' into search_bar
Leekao Sep 2, 2018
1db0419
dopush
Aminadav Sep 2, 2018
6c893b2
add google tag manager for hotjar
Aminadav Sep 2, 2018
f71d91e
[F] added search to redux
Leekao Sep 2, 2018
a83ae89
shopping-cart lead price is now aligned right
noamsilver Sep 2, 2018
6dbdd0c
Merge branch 'production' into noam
noamsilver Sep 2, 2018
3e7b811
Merge branch 'erez' into noam
noamsilver Sep 2, 2018
cb672dd
changed inline-manual loading animation
noamsilver Sep 2, 2018
94aade1
[B] stats endpoint
Leekao Sep 2, 2018
5bbd4df
[B] fixed broken commit
Leekao Sep 3, 2018
81d5752
[F] added ajax-loader to searchResults, added search_bar element with…
Leekao Sep 3, 2018
6836747
Merge remote-tracking branch 'origin/search_bar' into erez
Leekao Sep 3, 2018
7ba8a53
[P] now works even when search_bar present, also fixed typo in exit code
Leekao Sep 3, 2018
a357ca9
[B] no longer search for contact person
Leekao Sep 3, 2018
eeb110b
added back the move my-leads to sell with refactoring of the
noamsilver Sep 3, 2018
87055aa
Merge remote-tracking branch 'origin/erez' into next
Aminadav Sep 3, 2018
339887b
fix conflict in scss
Aminadav Sep 3, 2018
f743f17
[B] sql queries now properly escape field names with / or space
Leekao Sep 4, 2018
bdabc78
Merge remote-tracking branch 'origin/next' into erez
Leekao Sep 4, 2018
7b75652
Merge branch 'erez' into noam
noamsilver Sep 4, 2018
ed0952d
added filter functionality to leads views
noamsilver Sep 4, 2018
8ad9f5d
added to the mysql query builder the new filters options
noamsilver Sep 4, 2018
5fa39cd
fixed query, leads, cards, saga, demo leads
noamsilver Sep 5, 2018
b9d809d
add request for feedback when finish
Aminadav Sep 5, 2018
af1dedb
Merge remote-tracking branch 'origin/erez' into next
Aminadav Sep 5, 2018
c953c39
Merge remote-tracking branch 'origin/filters' into next
Aminadav Sep 5, 2018
db9899d
created a ConfirmationDialog component and added it to the CSVUpload
noamsilver Sep 5, 2018
1d04755
Merge branch 'next' into noam
noamsilver Sep 5, 2018
71c3434
added confirmation dialog to AddLead, fixed dialog positioning
noamsilver Sep 5, 2018
8ae2097
added the confirmation to MyLeads and changed the dialog's default text
noamsilver Sep 5, 2018
dcc32fe
[C] added cypress.json
Leekao Sep 5, 2018
0eca89d
[C] login spec stub
Leekao Sep 5, 2018
bb407d0
Revert "[B] sql queries now properly escape field names with / or space"
Leekao Sep 5, 2018
6132f61
[C] fixed bad commited file
Leekao Sep 5, 2018
448dd5d
Merge branch 'erez' of https://github.com/LeadcoinNetwork/Web-App-Pro…
Leekao Sep 6, 2018
d7c62c6
merged with next and noam
Leekao Sep 6, 2018
933d793
Merge remote-tracking branch 'origin/noam' into erez
Leekao Sep 6, 2018
1134f52
fix in buy-leads for no leads displayed while loading
noamsilver Sep 6, 2018
b6e7ee9
mock leads now have the new fields
noamsilver Sep 6, 2018
1352293
added loading flag while waiting for fetch leads
noamsilver Sep 6, 2018
17803ac
removed batch_id
noamsilver Sep 6, 2018
a0e76ae
added back button to csvUpload, addLead, displayLead,
noamsilver Sep 6, 2018
9ef72ca
broken mid-commit
Leekao Sep 12, 2018
d7c678d
mended broken commit: [B] leads/update added [F] EditLeads container …
Leekao Sep 12, 2018
229debb
Merge remote-tracking branch 'origin/noam' into erez
Leekao Sep 13, 2018
4bf9dbb
[B] added getSingleLead endpoint, added editLead endpoint [F] added e…
Leekao Sep 13, 2018
41f0098
[F] added edit lead button to card view, moved eye and pencil svgs to…
Leekao Sep 16, 2018
df03750
[F] removes unwanted cypress dep
Leekao Sep 16, 2018
0c2b47c
removed cypress deps
Leekao Sep 16, 2018
6ddc320
add temp file for trigger jenkins
Aminadav Sep 16, 2018
ce55d66
[B] added check for '/' on json field names
Leekao Sep 16, 2018
5a13abd
fixed ajax loader on search
noamsilver Sep 16, 2018
9062c7b
removed unused lodash import
noamsilver Sep 16, 2018
144b742
fixed edit button on cards view and updated styles
noamsilver Sep 16, 2018
a24f2be
fix last step?
Aminadav Sep 16, 2018
7d19cd3
[F] gonative apps will no longer see google connect
Leekao Oct 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/app-logic/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ export default class Auth {
if (shouldValidate) {
var rs = await UserValidate.checkNewUserValid(user)
if (rs instanceof Error) {
throw rs
//@ts-ignore
const errors = rs.details.map(ve => {
const key = ve.path[0]
return `${key}::${ve.message}`
})
throw errors.join(" ;")
}
if (!this.models.config.AUTO_CONFIRM_EMAIL) {
user.disabled = disabledReason.EMAIL_NOT_VERIFIED
Expand Down
10 changes: 10 additions & 0 deletions backend/app-logic/blockchain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IModels } from "./index"
//import { Transaction } from "../models/notifications/types"

export default class Blockchain {
constructor(private models: IModels) {}

public async logTransaction(user_id: number): Promise<string> {
return [notifications, unreadCount]
}
}
81 changes: 72 additions & 9 deletions backend/app-logic/leads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ import { IModels } from "./index"
import { Notification } from "../models/notifications/types"

import * as _ from "lodash"
import config from "./config"
var request = require("request-promise")

const logTransaction = async ({ fiat_amount, exchange_rate, leads_count }) => {
const res = await request({
uri: "http://blockchain.leadcoin.network/exchange",
method: "POST",
json: true,
body: {
fiat_amount,
exchange_rate,
leads_count,
},
})
return res
//{ txid: '0x9d6cd285dd8ac7bde247da8943ca2b536f58d7cac79deac975ba48766901eb68',
// link: 'http://ropsten.etherscan.io/tx/0x9d6cd285dd8ac7bde247da8943ca2b536f58d7cac79deac975ba48766901eb68' }
}

export interface getLeadsOptions {
sort_by?: [string, "ASC" | "DESC"]
Expand All @@ -16,11 +34,11 @@ const contains_contact = lead => {
return lead.telephone || lead.name || lead.email || lead["Contact Person"]
}

const validate_lead = (lead) => {
const validate_lead = lead => {
const errors = []
if (!lead.lead_price) errors.push("lead_price::Lead price is required")
if (!lead.lead_price) errors.push("lead_price::Lead price is required.")
if (!contains_contact(lead)) {
errors.push("phone::At least one contact info is required")
errors.push("phone::At least one contact info is required.")
errors.push("name::")
errors.push("email::")
}
Expand All @@ -33,6 +51,18 @@ export default class Leads {
constructor(private models: IModels) {}
public UploadCSV() {}

public async getOwnedLeads() {
return await this.models.leads.getOwnedLeads()
}

public async getSingleLead(id) {
return await this.models.leads.getSingleLead(id)
}

public async getOwners() {
return await this.models.leads.getOwners()
}

public async moveMyLeadsToSellLeads(leads: number[]) {
return await this.models.leads.moveMyToSell(leads)
}
Expand All @@ -49,7 +79,7 @@ export default class Leads {
}
buyer.balance = buyer.balance | 0
if (buyer.balance < deal_price) {
throw new Error("balance::Amount insufficient")
throw new Error("balance::Amount insufficient.")
}
const result = await this.models.leads.buy(leads, new_owner)
const groupedByOwner = _.groupBy(result, "bought_from")
Expand All @@ -61,15 +91,29 @@ export default class Leads {
overall_cost += transaction_amount
this.models.users.increaseBalance(seller, transaction_amount)
this.models.notifications.createNotification({
msg: `${
msg: `Someone bought ${
group.length
} of your leads were bought for a total of ${overall_cost}$`,
} of your leads for a total of ${overall_cost}$.`,
userId: seller,
unread: true,
})
}
this.models.users.decreaseBalance(new_owner, overall_cost)
return result
const txDetails = await logTransaction({
leads_count: result.length.toString(),
fiat_amount: (overall_cost * 100).toString(),
exchange_rate: "1999000000000000000",
})
/*
I'll just comment this part out instead of deleting it, maybe they'll want it back someday (@Leekao)

this.models.notifications.createNotification({
msg: "Your transaction was logged to " + txDetails.link,
userId: new_owner,
unread: true,
})
*/
return txDetails
}

public async removeLead(lead_id: number) {
Expand All @@ -94,6 +138,20 @@ export default class Leads {
throw new Error(problems.join(" ;"))
}

public async EditLead(lead: Lead) {
const problems = validate_lead(lead)
if (problems.length > 0) throw new Error(problems.join(" ;"))
lead = await this.sanitizeLead(lead)
const current_lead = await this.models.leads.getSingleLead(lead.id)
console.log({ current_lead, lead })
switch (true) {
case current_lead.ownerId != lead.ownerId:
case !current_lead.active:
throw new Error("general::lead mutated.")
}
return await this.models.leads.EditLead(lead)
}

public async getMockLeads(user_id: number) {
return await this.models.leads.getMockLeads(user_id)
}
Expand All @@ -107,11 +165,16 @@ export default class Leads {
}

public async getMyLeads(user_id: number, options: LeadQueryOptions) {
return await this.models.leads.getMyLeads(user_id, options)
const leads = await this.models.leads.getMyLeads(user_id, options)
return leads
}

public async getBoughtLeads(user_id: number, options: LeadQueryOptions) {
return await this.models.leads.getBoughtLeads(user_id, options)
const leads = await this.models.leads.getBoughtLeads(user_id, options)
leads.list = leads.list.map(l => {
return Object.assign(l, { lead_price: null })
})
return leads
}

public async getAllLeads(options: LeadQueryOptions) {
Expand Down
78 changes: 61 additions & 17 deletions backend/models/base-db-model/base-db-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ export default abstract class BaseDBModel<INew, IExisting, ICondition> {
}

leadsQueries = {
getOwnedLeads: async () => {
let sql = `
SELECT count(id) as cid
FROM leadcoin.leads
WHERE
doc->>"$.ownerId" > 0
AND doc->>"$.bought_from" > 0
;`
let rows = await this.sql.query(sql)
return rows.map(r => r.cid)
},
getOwners: async () => {
let sql = `
SELECT DISTINCT doc->>"$.ownerId" as owner
FROM leadcoin.leads
WHERE
doc->>"$.ownerId" > 0
AND doc->>"$.bought_from" > 0
;`
let rows = await this.sql.query(sql)
return rows.map(r => r.owner)
},
getMockLeads: async user_id => {
let sql = `
SELECT id
Expand Down Expand Up @@ -121,11 +143,12 @@ export default abstract class BaseDBModel<INew, IExisting, ICondition> {
getBoughtLeads: async (user_id: number, options: any) => {
const { limit, filters, sort } = options
let where_additions = []

if (filters) {
where_additions = filters
.map(f => {
const escaped = mysql.escape(f.val)
return `${this.fieldName} ->> "$.${f.field}" ${
return `${this.fieldName}->>${mysql.escape("$." + f.field)} ${
f.op
} "%${escaped.slice(1, -1)}%"`
})
Expand Down Expand Up @@ -157,38 +180,56 @@ export default abstract class BaseDBModel<INew, IExisting, ICondition> {
},

buyLeadsGetAll: async (options: any) => {
const { limit, filters, sort } = options
let where_additions = []
if (filters) {
where_additions = filters
const { limit, filters, sort, user_id } = options
let where_additions = ""
let search_additions = []
if (filters.search) {
search_additions = filters.search
.map(f => {
const escaped = mysql.escape(f.val)
return `${this.fieldName} ->> "$.${f.field}" ${
if (f.field.includes(" ")) f.field = '"' + f.field + '"'
if (f.field.includes("/")) f.field = '"' + f.field + '"'
return `${this.fieldName}->>${mysql.escape("$." + f.field)} ${
f.op
} "%${escaped.slice(1, -1)}%"`
})
.join(" OR ")
.join(`\nOR `)
}
if (filters.industry)
where_additions = `${this.fieldName}->>'$.Industry' = '${
filters.industry
}'`
if (filters.category)
where_additions +=
(where_additions ? `\nAND ` : "") +
`${this.fieldName}->>'$.Category' = '${filters.category}'`
if (search_additions.length > 0)
where_additions +=
(where_additions ? `\nAND ` : "") + "(" + search_additions + ")"
let limit_addition = ""
let countHeader = "SELECT COUNT(*) as count "
let realHeader = "SELECT *"
let query = `
FROM leads
WHERE doc->>"$.active" = "true"
AND doc->>"$.forSale" = "true"
`
if (where_additions.length > 0) query += `AND ${where_additions}`
let query = `\nFROM leads\nWHERE doc->>'$.active' = 'true'\nAND doc->>'$.forSale' = 'true'`
if (user_id) query += `\nAND doc->>'$.ownerId' <> ${user_id} `
if (where_additions) query += `\nAND ${where_additions}`
if (sort) {
query += ` ORDER BY ${this.fieldName} ->> ${mysql.escape(
query += `\nORDER BY ${this.fieldName}->>${mysql.escape(
"$." + sort.sortBy,
)} ${sort.sortOrder}`
}
if (limit) {
limit_addition += ` LIMIT ${limit.start},${limit.offset} `
limit_addition += `\nLIMIT ${limit.start},${limit.offset} `
}
let count = await this.sql.query(countHeader + query)
let rows = await this.sql.query(realHeader + query + limit_addition)
rows = rows.map(row => this.convertRowToObject(row)) // remove RowDataPacket class
rows = rows.map(row => {
return Object.assign(row, {
"Contact Person": "**********",
Email: "*********@gmail.com",
Telephone: row["Telephone"].substring(0, 6) + "******",
})
}) // remove contact information
return { list: rows, total: count[0].count }
},

Expand Down Expand Up @@ -236,7 +277,7 @@ export default abstract class BaseDBModel<INew, IExisting, ICondition> {
where_additions = filters
.map(f => {
const escaped = mysql.escape(f.val)
return `${this.fieldName} ->> "$.${f.field}" ${
return `${this.fieldName} ->> ${mysql.escape("$." + f.field)} ${
f.op
} "%${escaped.slice(1, -1)}%"`
})
Expand Down Expand Up @@ -374,7 +415,10 @@ export default abstract class BaseDBModel<INew, IExisting, ICondition> {
this.log("update " + this.tableName + " start", record)
var str = ""
var values = Object.keys(record).forEach(key => {
str += `, ${mysql.escape("$." + key)} , ${mysql.escape(record[key])}`
const value = record[key]
if (key.includes(" ")) key = '"' + key + '"'
if (key.includes("/")) key = '"' + key + '"'
str += `, ${mysql.escape("$." + key)} , ${mysql.escape(value)}`
})

var query = `UPDATE ${this.tableName} SET ${this.fieldName}=JSON_SET(${
Expand Down
2 changes: 1 addition & 1 deletion backend/models/csv_reader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function parseMappedFile(
) {
let records = papaparse.parse(fileContents, parseConfig).data
const leads = records.map(line => {
const lead: NewRealEstateLead = {
const lead = {
lead_price,
ownerId: user_id,
date: new Date().valueOf(),
Expand Down
7 changes: 0 additions & 7 deletions backend/models/email-creator/email-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ class EmailCreator {
"Temporary password: " +
password +
"<br><br>" +
"This password is temporary, so please " +
'<a href="' +
this.backend +
"/login" +
'">' +
"login" +
"</a> and immediately change it.<br><br> " +
"Best Regards,<br><br>" +
"The LeadCoin Team",
}
Expand Down
15 changes: 15 additions & 0 deletions backend/models/leads/leads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default class Leads extends baseDBModel<
return await this.insert(lead)
}

public async EditLead(lead: Lead) {
return await this.update(lead.id, lead)
}

public async insertLead(new_lead: Lead) {
return this.insert(new_lead)
}
Expand All @@ -34,6 +38,13 @@ export default class Leads extends baseDBModel<
return this.find({ condition, sort, limit })
}

public async getOwnedLeads() {
return await this.leadsQueries.getOwnedLeads()
}
public async getOwners() {
return await this.leadsQueries.getOwners()
}

public async getSoldLeads(user_id: number, options: LeadQueryOptions) {
return await this.leadsQueries.getSoldLeads(user_id, options)
}
Expand All @@ -54,6 +65,10 @@ export default class Leads extends baseDBModel<
return await this.leadsQueries.getMyLeads(user_id, options)
}

public async getSingleLead(lead_id: number) {
return await this.getById(lead_id)
}

public async getDealPrice(lead_ids: number[]) {
return await this.leadsQueries.getDealPrice(lead_ids)
}
Expand Down
Loading