-
Notifications
You must be signed in to change notification settings - Fork 832
18m Solution #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18m
Are you sure you want to change the base?
18m Solution #114
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noticed that the estimatedDeliveryTime
response from the POST /orders
does not use isWeekend().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does not. But the "skipping weekends part" was an exercise. Lesson 15 Exercise 15m.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@a10n-jsd use this code
const matchedOption = findDeliveryOption(order.orderTime, productDetails.estimatedDeliveryTime);
console.log(matchedOption);
let deliveryDate = 'undefined';
if(matchedOption){
deliveryDate = calculateDeliveryDateFrom(order.orderTime, matchedOption);
}
<div class="product-quantity">
Quantity: ${productDetails.quantity}
</div>
// all this code for skipping weekends from product-delivery-date
// to skip weekends we need deliveryOptions.deliveryDays
// but the products we get from backend doesnt have deliveryOption, and we cant change backend
// so here is the code for finding an deliveryOption, which we can use in our function
function countDaysBetween(startDate, endDate) {
// .diff is built-in method of dayjs which calculates tha difference between two dates in days
return dayjs(endDate).diff(dayjs(startDate), 'day');
}
function findDeliveryOption(orderTime, estimatedDeliveryTime){
const daysBetween = countDaysBetween(orderTime, estimatedDeliveryTime);
return deliveryOptions.find(option => option.deliveryDays === daysBetween) || null;
}
Alternate version of calculateDeliveryDate(). Put this code in deliveryOptions.js
export function calculateDeliveryDateFrom(orderTime, deliveryOption){
let orderDate = dayjs(orderTime);
let daysAdded = 0;
while(daysAdded < deliveryOption.deliveryDays){
orderDate = orderDate.add(1, 'day');
//skip weekends: 0 = Sunday, 6 = Saturday
if(orderDate.day() !== 0 && orderDate.day() !== 6){
daysAdded++;
}
}
return orderDate.format('MMMM D');
}
this calculates not from current date but the day we ordered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@im-anuj thanks dude!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please tell where do we have to put the code you gave above alternate version of calculatedeliverydate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can put these code at bottom of deliveryOptions.js file, and then can import in order.js and tracking.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if anyone having problems, you can checkout my repo- https://github.com/im-anuj/shopping-site-vanilla
i have done all the assignments and modified it a bit, hope it helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks i just put it inside order.js and made it a function so i can export it to tracking.
how do you guys solve the addToCart quantity problem and also the quantity changes after clicking 'buy again' button ? |
` addToCart(productId){
}` this is my addToCart code inside the cart Class |
Hi. I had published the project on github and deployed it through github
pages. After some time, they disabled my repository. Any idea why this
happened? It says i violated GitHub Trademark policy
…On Fri, Aug 1, 2025 at 12:14 PM Anuj Rawat ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
On 2-copy-of-code/lesson-18/scripts/orders.js
<#114 (comment)>
:
if anyone having problems, you can checkout my repo-
https://github.com/im-anuj/shopping-site-vanilla
i have done all the assignments and modified it a bit, hope it helps.
—
Reply to this email directly, view it on GitHub
<#114 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5NL5BI6LR2JC6CPDWB4RI33LMEDLAVCNFSM6AAAAABY2V2DAOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTANZXHE2DMOJUGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hey, same thing happened to me recently! What worked for me: Renamed the repo (removed "Amazon" from the name) Added a visible disclaimer (like a alert/popup saying it's just an educational project) Then I contacted GitHub here: https://support.github.com/contact/reinstatement Hope this helps! |
Thanks, I'll check it out. I had uploaded it as Amazon_Project so I guess I
will change that. But how do I make sure the site doesn't collect data. Do
I need to remove localstorage?
…On Fri, Aug 1, 2025, 3:15 PM Anuj Rawat ***@***.***> wrote:
*im-anuj* left a comment (SuperSimpleDev/javascript-course#114)
<#114 (comment)>
Hey, same thing happened to me recently!
I had uploaded this project, and GitHub disabled the repo saying it
violated their trademark policy.
What worked for me:
Renamed the repo (removed "Amazon" from the name)
Added a visible disclaimer (like a popup saying it's just an educational
project)
Made sure the site doesn't collect any data
Then I contacted GitHub here:
https://support.github.com/contact/reinstatement
They gave me 3 days to fix it and reinstated the repo after that.
Hope this helps!
—
Reply to this email directly, view it on GitHub
<#114 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5NL5BMDJMXNLUL3VNSTGZL3LMZK3AVCNFSM6AAAAABY2V2DAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCNBTHEZDOOBXGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
No its perfectly fine, you just need to message them that i have made changes , and its a static website it does not collect user's data |
Thank you very much. I got scared thinking my account was disabled
…On Fri, Aug 1, 2025 at 3:21 PM Anuj Rawat ***@***.***> wrote:
*im-anuj* left a comment (SuperSimpleDev/javascript-course#114)
<#114 (comment)>
No its perfectly fine, you just need to message them that i have made
changes , and its a static website it does not collect user's data
—
Reply to this email directly, view it on GitHub
<#114 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5NL5BODCWU2KS6B2LFPIZT3LM2D3AVCNFSM6AAAAABY2V2DAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCNBTHE2DSNJSGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
No description provided.