Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions frontend/src/pages/shoppingLists/CompletedListView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link } from "react-router";
import type { ShoppingList } from "./shoppingListTypes";
import "./CompletedListView.css";
import "../../components/button/Button.css";
import Button from "../../components/button/Button";

type CompletedListViewProps = {
list: ShoppingList;
Expand Down Expand Up @@ -167,23 +167,17 @@ function CompletedListView({ list }: CompletedListViewProps) {
</div>

{/* Knappene kobles til backend senere (#63) */}
<button
type="button"
className="button button--primary button--l list-summary__button"
>
<Button variant="primary" size="l" className="list-summary__button">
<span aria-hidden="true">↻</span> Bruk på nytt
</button>
</Button>
<p className="list-summary__info">
Lager en ny aktiv lapp med de samme varene. Prisene oppdateres til
dagens priser.
</p>

<button
type="button"
className="button button--secondary button--l list-summary__button"
>
<Button variant="secondary" size="l" className="list-summary__button">
Legg varer på aktiv lapp
</button>
</Button>

<button type="button" className="completed-list__delete">
SLETT LISTA
Expand Down
14 changes: 0 additions & 14 deletions frontend/src/pages/shoppingLists/ShoppingListDetailPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,6 @@
list-style: none;
}

/* Hele navnefeltet er klikkbart for å krysse av */
.notepad__list .shopping-list-row__name {
cursor: pointer;
}

.notepad__list .shopping-list-row__price {
text-transform: uppercase;
}

.notepad__list .quantity-stepper__button:disabled {
opacity: 0.4;
cursor: default;
}

/* «Legg til vare» nederst på lappen */
.notepad__add {
display: flex;
Expand Down
101 changes: 20 additions & 81 deletions frontend/src/pages/shoppingLists/ShoppingListDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useState } from "react";
import type { FormEvent } from "react";
import type { SubmitEvent } from "react";
import { Link, useParams } from "react-router";
import { mockLists } from "./shoppingListMockData";
import type { ShoppingListItem } from "./shoppingListTypes";
import "./ShoppingListDetailPage.css";
import "../../components/shoppingListRow/ShoppingListRow.css";
import "../../components/checkbox/Checkbox.css";
import "../../components/quantityStepper/QuantityStepper.css";
import "../../components/button/Button.css";
import Button from "../../components/button/Button";
import ShoppingListRow from "../../components/shoppingListRow/ShoppingListRow";
import CompletedListView from "./CompletedListView";

type SortOrder = "added" | "alphabetical";
Expand Down Expand Up @@ -68,7 +66,7 @@ function ShoppingListDetailPage() {
setItems((current) => current.filter((item) => item.id !== itemId));
}

function addItem(event: FormEvent<HTMLFormElement>) {
function addItem(event: SubmitEvent<HTMLFormElement>) {
event.preventDefault();
const name = newItem.trim();
if (!name) return;
Expand Down Expand Up @@ -156,72 +154,19 @@ function ShoppingListDetailPage() {

<ul className="notepad__list">
{sortedItems.map((item) => (
<li
<ShoppingListRow
key={item.id}
className={`shopping-list-row ${item.checked ? "shopping-list-row--checked" : ""}`}
>
<input
id={`item-${item.id}`}
type="checkbox"
className="checkbox checkbox--large"
checked={item.checked}
onChange={() => toggleChecked(item.id)}
/>
<label
htmlFor={`item-${item.id}`}
className="shopping-list-row__name"
>
<span className="shopping-list-row__item">
{item.name}
</span>
{item.note && (
<span className="shopping-list-row__note">
{item.note}
</span>
)}
</label>

<div className="quantity-stepper">
<button
type="button"
className="quantity-stepper__button"
aria-label={`Færre ${item.name}`}
onClick={() => changeQuantity(item.id, -1)}
disabled={item.quantity <= 1}
>
−
</button>
<span
className="quantity-stepper__value"
aria-live="polite"
>
{item.quantity}
</span>
<button
type="button"
className="quantity-stepper__button"
aria-label={`Flere ${item.name}`}
onClick={() => changeQuantity(item.id, 1)}
>
+
</button>
</div>

<span className="shopping-list-row__price">
{item.unitPrice == null
? "—"
: `${formatPrice(item.unitPrice * item.quantity)} KR`}
</span>

<button
type="button"
className="shopping-list-row__remove"
aria-label={`Fjern ${item.name}`}
onClick={() => removeItem(item.id)}
>
×
</button>
</li>
id={item.id}
name={item.name}
note={item.note}
quantity={item.quantity}
unitPrice={item.unitPrice}
checked={item.checked}
onToggle={() => toggleChecked(item.id)}
onDecrease={() => changeQuantity(item.id, -1)}
onIncrease={() => changeQuantity(item.id, 1)}
onRemove={() => removeItem(item.id)}
/>
))}
</ul>

Expand Down Expand Up @@ -280,24 +225,18 @@ function ShoppingListDetailPage() {
</p>
</div>

<button
type="button"
className="button button--primary button--l list-summary__button"
>
<Button variant="primary" size="l" className="list-summary__button">
Start handletur
</button>
</Button>
<Link
to="/search"
className="button button--secondary button--l list-summary__button"
>
Finn flere varer
</Link>
<button
type="button"
className="button button--secondary button--l list-summary__button"
>
<Button variant="secondary" size="l" className="list-summary__button">
Del lappen
</button>
</Button>

<p className="list-summary__info">
Lappen lagres automatisk. Prisene er estimat og kan endre seg i
Expand Down