Add used-product flag for store listings.
Merchants can mark items as used on create/edit, see a used badge on cards, and filter the store list for used products. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
32f0dbab63
commit
61d145d92e
@@ -72,6 +72,7 @@ export function EditStoreItemsModal({
|
||||
const [variations, setVariations] = useState<ProductVariationSelection[]>([])
|
||||
const [rows, setRows] = useState<StoreItemDraftRow[]>([])
|
||||
const [removedIds, setRemovedIds] = useState<string[]>([])
|
||||
const [isUsed, setIsUsed] = useState(false)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
@@ -123,6 +124,7 @@ export function EditStoreItemsModal({
|
||||
setClosing(false)
|
||||
setRemovedIds([])
|
||||
setRows(itemsToRows(items))
|
||||
setIsUsed(items.some((item) => item.isUsed))
|
||||
setError('')
|
||||
const controller = new AbortController()
|
||||
void loadVariations(productId, controller.signal)
|
||||
@@ -223,6 +225,7 @@ export function EditStoreItemsModal({
|
||||
try {
|
||||
const data = await syncProductStoreItems({
|
||||
productId,
|
||||
isUsed,
|
||||
items: rows.map((row) => ({
|
||||
id: row.storeItemId,
|
||||
selections: formVariations.flatMap((variation) => {
|
||||
@@ -294,6 +297,17 @@ export function EditStoreItemsModal({
|
||||
<p className={modalStyles.emptyText}>{t('storeItems.create.loadingVariations')}</p>
|
||||
) : (
|
||||
<>
|
||||
<label className={rowStyles.usedCheckLabel}>
|
||||
<input
|
||||
type="checkbox"
|
||||
className={rowStyles.usedCheck}
|
||||
checked={isUsed}
|
||||
onChange={(e) => setIsUsed(e.target.checked)}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
<span>{t('storeItems.create.isUsed')}</span>
|
||||
</label>
|
||||
|
||||
<div
|
||||
className={rowStyles.itemRowHeader}
|
||||
style={{ gridTemplateColumns: gridTemplate }}
|
||||
|
||||
Reference in New Issue
Block a user