@@ -67,8 +67,7 @@ export const Lead = ObjectSchema.create({
6767 } ) ,
6868
6969 // Lead Qualification
70- status : {
71- type : 'select' ,
70+ status : Field . select ( {
7271 label : 'Lead Status' ,
7372 required : true ,
7473 options : [
@@ -78,17 +77,13 @@ export const Lead = ObjectSchema.create({
7877 { label : 'Unqualified' , value : 'unqualified' , color : '#FF0000' } ,
7978 { label : 'Converted' , value : 'converted' , color : '#00AA00' } ,
8079 ]
81- } ,
80+ } ) ,
8281
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- } ,
82+ rating : Field . rating ( 5 , {
83+ label : 'Lead Score' ,
84+ description : 'Lead quality score (1-5 stars)' ,
85+ allowHalf : true ,
86+ } ) ,
9287
9388 lead_source : Field . select ( [ 'Web' , 'Referral' , 'Event' , 'Partner' , 'Advertisement' , 'Cold Call' ] , {
9489 label : 'Lead Source' ,
@@ -127,12 +122,11 @@ export const Lead = ObjectSchema.create({
127122 readonly : true ,
128123 } ) ,
129124
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' } ) ,
125+ // Address (using new address field type)
126+ address : Field . address ( {
127+ label : 'Address' ,
128+ addressFormat : 'international' ,
129+ } ) ,
136130
137131 // Additional Info
138132 annual_revenue : Field . currency ( {
@@ -148,6 +142,12 @@ export const Lead = ObjectSchema.create({
148142 label : 'Description' ,
149143 } ) ,
150144
145+ // Custom notes with rich text formatting
146+ notes : Field . richtext ( {
147+ label : 'Notes' ,
148+ description : 'Rich text notes with formatting' ,
149+ } ) ,
150+
151151 // Flags
152152 do_not_call : Field . boolean ( {
153153 label : 'Do Not Call' ,
@@ -160,6 +160,14 @@ export const Lead = ObjectSchema.create({
160160 } ) ,
161161 } ,
162162
163+ // Database indexes for performance
164+ indexes : [
165+ { fields : [ 'email' ] , unique : true } ,
166+ { fields : [ 'owner' ] , unique : false } ,
167+ { fields : [ 'status' ] , unique : false } ,
168+ { fields : [ 'company' ] , unique : false } ,
169+ ] ,
170+
163171 enable : {
164172 trackHistory : true ,
165173 searchable : true ,
@@ -193,11 +201,11 @@ export const Lead = ObjectSchema.create({
193201 sort : [ { field : 'created_date' , order : 'desc' } ] ,
194202 } ,
195203 hot_leads : {
196- label : 'Hot Leads' ,
204+ label : 'High Score Leads' ,
197205 type : 'grid' ,
198- columns : [ 'full_name' , 'company' , 'email' , 'phone' , 'status' , 'owner' ] ,
206+ columns : [ 'full_name' , 'company' , 'email' , 'phone' , 'status' , 'rating' , ' owner'] ,
199207 filter : [
200- [ 'rating' , '=' , 'hot' ] ,
208+ [ 'rating' , '> =' , 4 ] ,
201209 [ 'is_converted' , '=' , false ] ,
202210 ] ,
203211 } ,
@@ -235,13 +243,13 @@ export const Lead = ObjectSchema.create({
235243 {
236244 label : 'Address' ,
237245 columns : 2 ,
238- fields : [ 'street' , 'city' , 'state' , 'postal_code' , 'country '] ,
246+ fields : [ 'address ' ] ,
239247 } ,
240248 {
241249 label : 'Additional Information' ,
242250 columns : 2 ,
243251 collapsible : true ,
244- fields : [ 'do_not_call' , 'email_opt_out' , 'description' ] ,
252+ fields : [ 'do_not_call' , 'email_opt_out' , 'description' , 'notes' ] ,
245253 } ,
246254 {
247255 label : 'Conversion Information' ,
@@ -273,10 +281,10 @@ export const Lead = ObjectSchema.create({
273281
274282 workflows : [
275283 {
276- name : 'auto_qualify_hot_leads ' ,
284+ name : 'auto_qualify_high_score_leads ' ,
277285 objectName : 'lead' ,
278286 triggerType : 'on_create_or_update' ,
279- criteria : 'rating = "hot" AND status = "new"' ,
287+ criteria : 'rating >= 4 AND status = "new"' ,
280288 active : true ,
281289 actions : [
282290 {
@@ -288,16 +296,16 @@ export const Lead = ObjectSchema.create({
288296 ] ,
289297 } ,
290298 {
291- name : 'notify_owner_on_hot_lead ' ,
299+ name : 'notify_owner_on_high_score_lead ' ,
292300 objectName : 'lead' ,
293301 triggerType : 'on_create_or_update' ,
294- criteria : 'ISCHANGED(rating) AND rating = "hot" ' ,
302+ criteria : 'ISCHANGED(rating) AND rating >= 4.5 ' ,
295303 active : true ,
296304 actions : [
297305 {
298306 name : 'email_owner' ,
299307 type : 'email_alert' ,
300- template : 'hot_lead_notification ' ,
308+ template : 'high_score_lead_notification ' ,
301309 recipients : [ '{owner.email}' ] ,
302310 }
303311 ] ,
0 commit comments