Hi:
I set an expiration date for my customer as a warranty information display (2-year warranty). Everything was great until last weekend, the repeater in the profile page of my customer is showing undefined/NaN/NaN. I have not changed the code so I don’t know what to do. Please help. : (
Here’s the screenshot of the repeater, the “Expiration Date” should say 7/1/22 instead of undefined/NaN/NaN
There’s been an error notification since I complete the code, but it did not have any problems displaying the expiration date before. Is there any update about the code that I missed?
I also include the code as follows:
The code on the profile page:
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
$w ( “#repeater1” ). onItemReady ( ( $item , itemData , index ) => {
$item ( “#expiredtime” ). text = itemData . expiredTime ;
});
$w ( “#table1” ). columns = [
{
“id” : “col1” ,
“dataPath” : “orderNo” ,
“label” : “Order Number” ,
“type” : “string”
},
//{
//“id”:“col2”,
//“dataPath”:“youProductOrderDate”,
//“label”:“Order Date”,
//“type”:“string”
//},
{
“id” : “col2” ,
“dataPath” : “expiredTime” ,
“label” : “Expiration Time” ,
“type” : “string”
}
]
$w ( “#productregistersumbit” ). onAfterSave ( ()=>{
$w ( “#dataset1” ). refresh ();
})
})
export function button5_click ( event ) {
wixData . query ( “ruqv4bl26cup3a” )
. eq ( “orderNo” , $w ( “#input5” ). value )
. or ( wixData . query ( “ruqv4bl26cup3a” ). eq ( “email” , $w ( “#input5” ). value ))
. find ()
. then ( res => {
$w ( “#table1” ). rows = res . items ;
})
// Add your code for this event here:
}
AND the code about setting the expiration date:
export function ruqv4bl26cup3a_afterQuery ( item ) {
item . expiredTime = setExpiredTime ( item . youProductOrderDate );
return item ;
function setExpiredTime ( youProductOrderDate ) {
var originalDate = new Date ( youProductOrderDate );
var date = new Date ( originalDate );
// set expiration 2 year
date . setDate ( date . getDate () + 731 );
**const** monthNames = [ "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" ];
**const** day = date . getDate (). toString ();
**const** longMonth = monthNames [ date . getMonth ()];
**const** year = date . getFullYear (). toString ();
**var** expiredTime = longMonth + "/" + day + "/" + year ;
**return** expiredTime . toString ();
}
}
English is not my native language, sorry for any mistake or possible misleading word usage in my post.
Thank you in advance!