pattern="/^\d{5}(?:-\d{4})?$/"
pattern="[^@\s]+@[^@\s]+\.[^@\s]+"
| /** | |
| * Can be used to set the time and timezone offset for simple Date comparisons. | |
| * @param {string} dateValue - Date to be converted | |
| * @param {number} [offset] - Timezone offset | |
| * @returns {number} - Converted date in milliseconds. | |
| */ | |
| export const normalizeTime = (dateValue, offset = undefined) => { | |
| if (dateValue) { | |
| const thisDate = new Date(dateValue); | |
| let msDate = thisDate.getTime(); |
| public without sharing class B2BCheckout { | |
| @AuraEnabled | |
| public static CartDeliveryGroup setPickupInformation(String notes, String pickupTime, Id cartDeliveryGroupId) { | |
| CartDeliveryGroup cartDeliveryGroup = [ | |
| SELECT Id, DeliveryMethodId | |
| FROM CartDeliveryGroup | |
| WHERE Id =: cartDeliveryGroupId | |
| ]; | |
| Datetime desiredDeliveryDate = Datetime.valueOfGmt(pickupTime.replace('T', ' ')); | |
| cartDeliveryGroup.ShippingInstructions = notes; |
| // Using add itemS to cart from the commerce/cartApi | |
| import { addItemsToCart } from "commerce/cartApi"; | |
| // Set up an array as a payload. | |
| const payload = [{ | |
| productId: this.productId, | |
| quantity: this.quantity, | |
| type: "Product" | |
| }]; |
| /* Returns a promise */ | |
| fetchCommerceUrl(url) { | |
| let apiver = 'v64.0'; | |
| let commercebase = '/webruntime/api/services/data/' + apiver + '/commerce'; | |
| let fullurl = commercebase + url; | |
| console.log('Begin fetchCommerceUrl on ', fullurl); | |
| return fetch(fullurl, { | |
| method: 'GET', |
| import checkoutApi from "commerce/checkoutApi"; | |
| import cartApi from "commerce/cartApi"; | |
| console.log("cartApi:", cartApi); | |
| console.log("cartApi keys:", Object.keys(cartApi)); | |
| // Optional: Log function names individually | |
| Object.keys(cartApi).forEach((key) => { | |
| console.log(`cartApi[${key}] =`, cartApi[key]); | |
| }); |
| /** | |
| * Wraps the startViewTransition to check avialability and reduced motion settings. | |
| * Usage: await viewTransition(() => {this.showElement = true}); | |
| * @param {Function} callback - callback to function that triggers the animation. | |
| * @returns {Promise<unknown>} - Finish transition. | |
| */ | |
| export const viewTransition = (callback) => { | |
| return new Promise((resolve) => { | |
| const mediaQuery = window.matchMedia('(prefers-reduced-motion)'); | |
| const isReducedMotion = mediaQuery.matches; |
| import { LightningElement } from 'lwc'; | |
| export default class BrowserNotificationsExample extends LightningElement { | |
| connectedCallback() { | |
| this.initPushNotifications(); | |
| } | |
| // Modified from: https://levelup.gitconnected.com/creating-browser-notification-in-javascript-79e91bfb76c8 | |
| initPushNotifications() { |