@@ -80,15 +80,11 @@ export const Lead = ObjectSchema.create({
8080 ]
8181 } ,
8282
83- rating : {
84- type : 'select' ,
85- label : 'Rating' ,
86- options : [
87- { label : 'Hot' , value : 'hot' , color : '#FF0000' } ,
88- { label : 'Warm' , value : 'warm' , color : '#FFA500' } ,
89- { label : 'Cold' , value : 'cold' , color : '#4169E1' } ,
90- ]
91- } ,
83+ rating : Field . rating ( 5 , {
84+ label : 'Lead Score' ,
85+ description : 'Lead quality score (1-5 stars)' ,
86+ allowHalf : true ,
87+ } ) ,
9288
9389 lead_source : Field . select ( [ 'Web' , 'Referral' , 'Event' , 'Partner' , 'Advertisement' , 'Cold Call' ] , {
9490 label : 'Lead Source' ,
@@ -127,12 +123,11 @@ export const Lead = ObjectSchema.create({
127123 readonly : true ,
128124 } ) ,
129125
130- // Address
131- street : Field . textarea ( { label : 'Street' } ) ,
132- city : Field . text ( { label : 'City' } ) ,
133- state : Field . text ( { label : 'State/Province' } ) ,
134- postal_code : Field . text ( { label : 'Postal Code' } ) ,
135- country : Field . text ( { label : 'Country' } ) ,
126+ // Address (using new address field type)
127+ address : Field . address ( {
128+ label : 'Address' ,
129+ addressFormat : 'international' ,
130+ } ) ,
136131
137132 // Additional Info
138133 annual_revenue : Field . currency ( {
@@ -148,6 +143,12 @@ export const Lead = ObjectSchema.create({
148143 label : 'Description' ,
149144 } ) ,
150145
146+ // Custom notes with rich text formatting
147+ notes : Field . richtext ( {
148+ label : 'Notes' ,
149+ description : 'Rich text notes with formatting' ,
150+ } ) ,
151+
151152 // Flags
152153 do_not_call : Field . boolean ( {
153154 label : 'Do Not Call' ,
@@ -160,6 +161,14 @@ export const Lead = ObjectSchema.create({
160161 } ) ,
161162 } ,
162163
164+ // Database indexes for performance
165+ indexes : [
166+ { fields : [ 'email' ] , unique : true } ,
167+ { fields : [ 'owner' ] , unique : false } ,
168+ { fields : [ 'status' ] , unique : false } ,
169+ { fields : [ 'company' ] , unique : false } ,
170+ ] ,
171+
163172 enable : {
164173 trackHistory : true ,
165174 searchable : true ,
@@ -235,13 +244,13 @@ export const Lead = ObjectSchema.create({
235244 {
236245 label : 'Address' ,
237246 columns : 2 ,
238- fields : [ 'street' , 'city' , 'state' , 'postal_code' , 'country '] ,
247+ fields : [ 'address ' ] ,
239248 } ,
240249 {
241250 label : 'Additional Information' ,
242251 columns : 2 ,
243252 collapsible : true ,
244- fields : [ 'do_not_call' , 'email_opt_out' , 'description' ] ,
253+ fields : [ 'do_not_call' , 'email_opt_out' , 'description' , 'notes' ] ,
245254 } ,
246255 {
247256 label : 'Conversion Information' ,
@@ -273,10 +282,10 @@ export const Lead = ObjectSchema.create({
273282
274283 workflows : [
275284 {
276- name : 'auto_qualify_hot_leads ' ,
285+ name : 'auto_qualify_high_score_leads ' ,
277286 objectName : 'lead' ,
278287 triggerType : 'on_create_or_update' ,
279- criteria : 'rating = "hot" AND status = "new"' ,
288+ criteria : 'rating >= 4 AND status = "new"' ,
280289 active : true ,
281290 actions : [
282291 {
@@ -288,16 +297,16 @@ export const Lead = ObjectSchema.create({
288297 ] ,
289298 } ,
290299 {
291- name : 'notify_owner_on_hot_lead ' ,
300+ name : 'notify_owner_on_high_score_lead ' ,
292301 objectName : 'lead' ,
293302 triggerType : 'on_create_or_update' ,
294- criteria : 'ISCHANGED(rating) AND rating = "hot" ' ,
303+ criteria : 'ISCHANGED(rating) AND rating >= 4.5 ' ,
295304 active : true ,
296305 actions : [
297306 {
298307 name : 'email_owner' ,
299308 type : 'email_alert' ,
300- template : 'hot_lead_notification ' ,
309+ template : 'high_score_lead_notification ' ,
301310 recipients : [ '{owner.email}' ] ,
302311 }
303312 ] ,
0 commit comments