is it ok to use Toast on my redux toolkit slice? - redux

I have a shopping cart and want to check if a item is not more in the cart than the item amount have.
So I have to check it, but if I have 10 items in cart and press my button and dispatch and check it, then my list are rerenered and my toast and my button are laagy. So I want to remove the checking/condition and want to add it in my redux slice, so it is ok to use the Toast in redux slice ? or is that bad pattern or something else ?

Related

How do I create a favorites button that will add the div to an html page called "My Watchlist"?

I'm trying to create a streaming service that has a custom watchlist that stores whatever the user marks as their favorite. On each card, there would be a play button and a favorites button. The favorites button would (if clicked) add that specific movie/tv show to their watchlist (which is on another page in the same website0 and save both the status of the favorites button to localstorage and save the movie/tv show to localstorage until they remove it. Can someone help me?
I haven't tried anything yet, which is why I need help.

Google Tag Manager- is there a way to track when a checkbox is selected and then the user hits the Checkout button on that same page?

Sorry if this is a dumb question. I'm a GTM noob and from googling I see tutorials on tracking the clicks (checkbox element and Checkout button) separately but was wondering if there's any way this can be one Event in Google Analytics.
For example, on our store's cart page a checkbox to add a product's accessory is selected by default. I want to know how many people are hitting the Checkout button and leaving this "add an accessory" checkbox checked.
Is there a way to push an Event as something like "Checkout click - Add On Checkbox - Selected"?
Thanks in advance!
Yes, you can detect if a checkbox is checked on any event, using a Custom Javascript variable, value of which you then can use in the trigger, or in your tag. Or in a different variable, of course.
If you provide the html of your checkbox, we can give you code for the variable to return the checkbox state if you're not comfortable with JS.
//Upd
In your code, you have a few errors. First, no need to name the function in the CJS variable. Also, you write a bit too much code and rely on JQuery with no need. It can be solved simpler with pure JS like so:
function(){
return document.querySelector("input#add-subscription").checked;
}
Now, about the rest of what you're saying. Having this checkbox action. You have a wrong understanding. This is not a checkbox action. This code only gets the state of the checkbox whenever the value of this variable is being used.
So if you're gonna use the value of this variable when a person clicks on the form submission CTA, then this code will run on that click, assessing the value of the checkbox.
Your amazon example works. But you don't need to assume that the checkbox is checked by default. The default doesn't mean anything here. The state of the checkbox is assessed on the trigger where the value of the CJS var is used, that's it.
We're proceeding with your question: I'm confused about having the multiple criteria (checkbox is checked and user hits Checkout button) and if including both as triggers would work You're making another mistake here. They're not both triggers. One of them is a trigger indeed, which is a click trigger. The other, however, is a condition for the trigger to fire. You know how in the trigger, you click the checkbox that says "some events"? This fella:
Once you have that, you can add conditions. Like, only use this trigger when... when what? Anything really. In our case it would be when the checkbox is true.
Finally, for the checkout click, you don't typically need more than just the click trigger with the CSS selector criteria.
Anyhow, to be short, this is about how your trigger should look like:
Thanks! In this case the checkbox element for my cart page is:
<input id="add-subscription" type="checkbox" checked="checked" class="form-checkbox js-product-subscribe-newux mt-10 sm:mt-0" name="sub" value="remove">
I was thinking the variable could be:
function checked() {
var check = jQuery('form-checkbox js-product-subscribe-newux mt-10 sm:mt-0').attr("checked");
if(check === "checked") {
return true;
} else {
return false;
}
}
However where I get confused is having this checkbox action (checkbox is checked) only count as an event when the user hits the Checkout button. Using this Amazon cart page as an example, assuming the "This is a gift" checkbox is clicked by default, "This is a gift" checkbox would I just then add the Trigger as having two criteria, roughly: {{Checkbox Variable}} = "true" & Click Text = "Proceed to Checkout? I'm confused about having the multiple criteria (checkbox is checked and user hits Checkout button) and if including both as triggers would work in this case so I can see how many times users click to checkout from the cart while leaving that box checked. Or would the Click on the Checkout button need to be it's own separate variable rather than just specifying the Checkout button name in the trigger criteria?

WKInterfacePicker: handle a tap event

Trying to simplify the UX in a Watch application by getting rid of a redundant button which a user has to tap in order to choose a selected item in WKInterfacePicker and perform a next step. Just want to replace the tap on this button with the tap on a picker.
Cannot find such API in the class specification and the following quote haunts me:
The user interacts with a picker by tapping it, using the crown to scroll through items, and tapping again to select an item.
Everything points to the fact that an item can be selected by tapping on a picker and we can get an access to that action programatically. Has anyone faced this task?
To handle focus to picker did tap event use - pickerDidFocus.
If you want handle each tap now there are only one custom way. You need every time did focus picker programmaticaly call [picker resignFocus]
Put picker into group and set background border image to it if you want to customize focus. Set picker focus style to none.
just add a picker to your WKInterfaceController and create an IBAction to react on the pitch events:

Change the NewPage for a TcxPageControl in the PageChanging event

We use a page control to step through a selection process from orders to products. The first tab shows a list of orders, the second tab shows a list of products for the selected order, and the 3rd tab contains a list of properties for the selected product.
If the user choose an order with only 1 product, we want to skip tab 2 and go straight to tab 3 to show the properties of the sole product.
I thought this could be done by setting the NewPage property of the PageChanging event, but it doesn't. What is a better way? To set the ActivePageIndex within the PageChanging event instead?
I would hide the tabs so the user cannot select them at all, and then use a pair of buttons to move back and forth between the pages as needed. When the user is on page 1 and is ready to move to the next page, the button handler can decide which page to show next.

click feature in Qt

I just want to clarify, weather the feature is present or not in Qt.
The scenario is like this,
I have a list view with items, I want to place the icon to the listview when the item is selected.
The selection I mean is, first time when I click item should be selected, next time if I click the same item then it should display some icon. Please note
It is not the double click. again if do select some other item same feature should continue
So is there any feature which handles this feature by default, any property or flag which I need to set to listview to behave like this or manual implementation
Is required for this.
No problem (: Now I understand what you mean... So if you click on an item it should be selected (for example highlighted in blue) and then when you click on this item again, an icon should be displayed.
I can't think of a regualar way to do this, there is no such flag or something.
The easiest way I can think of would be to store the index in a QList when you select it. And when you deselect it, you delete the index from the list. SO, when you click on an item you can check if it is in that list and if so you can display your icon.
Another way would be to create your own type of QModelIndex. Everytime, this index is selected, you set a bool like is_already_selected on true. When clicking on this item again you check this bool and then decide whether an icon should be displayed or not.
For further information, see: QListView, QAbstractItemView::currentIndex, QModelIndex

Resources