-
Notifications
You must be signed in to change notification settings - Fork 0
feat(admin,products): add seller detail page, product status actions, and confirm modal #101
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
Changes from all commits
5e9585a
e38d200
42be4ad
4d96820
08dcc13
9e1c46b
0e1268f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| .container { | ||
| max-width: 760px; | ||
| margin: 0 auto; | ||
| padding: var(--spacing-xl); | ||
| } | ||
|
|
||
| .header { | ||
| margin-bottom: var(--spacing-lg); | ||
| } | ||
|
|
||
| .backLink { | ||
| display: inline-flex; | ||
| margin-bottom: var(--spacing-sm); | ||
| color: var(--color-green-dark); | ||
| font-weight: var(--font-weight-medium); | ||
| } | ||
|
|
||
| .backLink:hover { | ||
| text-decoration: underline; | ||
| } | ||
|
|
||
| .kicker { | ||
| margin: 0 0 var(--spacing-xs); | ||
| color: var(--color-lila); | ||
| font-size: 0.9rem; | ||
| } | ||
|
|
||
| .title { | ||
| margin: 0; | ||
| font-size: 1.75rem; | ||
| color: var(--color-green-dark); | ||
| } | ||
|
|
||
| .summary { | ||
| display: grid; | ||
| gap: var(--spacing-md); | ||
| margin-bottom: var(--spacing-xl); | ||
| padding: var(--spacing-lg); | ||
| border-radius: 12px; | ||
| background: var(--color-white); | ||
| box-shadow: 0 1px 4px rgb(0 0 0 / 0.08); | ||
| } | ||
|
|
||
| .summaryRow { | ||
| display: grid; | ||
| gap: var(--spacing-xs); | ||
| } | ||
|
|
||
| .summaryLabel { | ||
| font-size: 0.8rem; | ||
| font-weight: var(--font-weight-semibold); | ||
| text-transform: uppercase; | ||
| letter-spacing: 0.04em; | ||
| color: var(--color-lila); | ||
| } | ||
|
|
||
| .summaryValue { | ||
| margin: 0; | ||
| font-size: 1rem; | ||
| color: #222; | ||
| } | ||
|
|
||
| .form { | ||
| display: grid; | ||
| gap: var(--spacing-md); | ||
| padding: var(--spacing-lg); | ||
| border-radius: 12px; | ||
| background: var(--color-white); | ||
| box-shadow: 0 1px 4px rgb(0 0 0 / 0.08); | ||
| } | ||
|
|
||
| .sectionTitle { | ||
| margin: 0; | ||
| font-size: 1.2rem; | ||
| color: var(--color-green-dark); | ||
| } | ||
|
|
||
| .field { | ||
| display: grid; | ||
| gap: var(--spacing-xs); | ||
| } | ||
|
|
||
| .label { | ||
| font-size: 0.9rem; | ||
| font-weight: var(--font-weight-medium); | ||
| color: #222; | ||
| } | ||
|
|
||
| .input, | ||
| .textarea { | ||
| width: 100%; | ||
| padding: 0.8rem 0.95rem; | ||
| border: 1px solid var(--color-lila); | ||
| border-radius: 8px; | ||
| background: var(--color-white); | ||
| color: #222; | ||
| } | ||
|
|
||
| .textarea { | ||
| resize: vertical; | ||
| min-height: 120px; | ||
| } | ||
|
|
||
| .successMessage { | ||
| padding: 0.75rem 1rem; | ||
| border-radius: 8px; | ||
| background: rgb(193 224 140 / 0.25); | ||
| color: var(--color-green-dark); | ||
| } | ||
|
|
||
| .formActions { | ||
| display: flex; | ||
| justify-content: flex-start; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { redirect, notFound } from 'next/navigation'; | ||
| import Link from 'next/link'; | ||
| import { container } from '@/composition-root/container'; | ||
| import { assertRole } from '@/shared/authorization/authorization'; | ||
| import { getDictionary } from '@/shared/i18n/get-dictionary'; | ||
| import { NotFoundError } from '@/shared/kernel/app-error'; | ||
| import { GetSellerUseCase } from '@/modules/sellers/application/use-cases/get-seller-use-case'; | ||
| import styles from './page.module.css'; | ||
| import { SellerDetailForm } from './seller-detail-form'; | ||
|
|
||
| export default async function AdminSellerDetailPage({ | ||
| params, | ||
| }: { | ||
| params: Promise<{ locale: string; sellerId: string }>; | ||
| }) { | ||
| const { locale, sellerId } = await params; | ||
|
|
||
| try { | ||
| await assertRole('ADMIN'); | ||
| } catch { | ||
| redirect(`/${locale}`); | ||
| } | ||
|
|
||
| const dict = await getDictionary(locale as 'es' | 'cat'); | ||
| const sellerRepository = container.getSellerRepository(); | ||
| const getSeller = new GetSellerUseCase(sellerRepository); | ||
|
|
||
| let seller; | ||
| try { | ||
| seller = await getSeller.execute({ sellerId }); | ||
| } catch (error) { | ||
| if (error instanceof NotFoundError) { | ||
| notFound(); | ||
| } | ||
|
|
||
| throw error; | ||
| } | ||
|
|
||
| return ( | ||
| <div className={styles.container}> | ||
| <header className={styles.header}> | ||
| <div> | ||
| <Link href={`/${locale}/admin/sellers`} className={styles.backLink}> | ||
| {dict.admin.backToSellers} | ||
| </Link> | ||
| <h2 className={styles.title}>{dict.admin.sellerDetail.editTitle}</h2> | ||
| </div> | ||
| </header> | ||
|
|
||
| <section | ||
| className={styles.summary} | ||
| aria-label={dict.admin.sellerDetail.editTitle} | ||
| > | ||
| <div className={styles.summaryRow}> | ||
| <span className={styles.summaryLabel}> | ||
| {dict.admin.sellerDetail.nameLabel} | ||
| </span> | ||
| <strong className={styles.summaryValue}>{seller.name}</strong> | ||
| </div> | ||
| <div className={styles.summaryRow}> | ||
| <span className={styles.summaryLabel}> | ||
| {dict.admin.sellerDetail.descriptionLabel} | ||
| </span> | ||
| <p className={styles.summaryValue}>{seller.description ?? '—'}</p> | ||
| </div> | ||
| </section> | ||
|
|
||
| <SellerDetailForm | ||
| sellerId={seller.sellerId.value} | ||
| nameLabel={dict.admin.sellerDetail.nameLabel} | ||
| descriptionLabel={dict.admin.sellerDetail.descriptionLabel} | ||
| saveLabel={dict.admin.sellerDetail.save} | ||
| savedLabel={dict.admin.sellerDetail.saved} | ||
| errorLabel={dict.admin.sellerDetail.error} | ||
| initialName={seller.name} | ||
| initialDescription={seller.description ?? ''} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,34 @@ | |
| pointer-events: none; | ||
| } | ||
|
|
||
| .statusBadge { | ||
| display: inline-block; | ||
| padding: 0.2rem 0.6rem; | ||
| border-radius: 4px; | ||
| font-size: 0.8rem; | ||
| font-weight: var(--font-weight-medium); | ||
| } | ||
|
|
||
| .statusBadge[data-status='active'] { | ||
| background: var(--color-green-light); | ||
| color: var(--color-green-dark); | ||
| } | ||
|
|
||
| .statusBadge[data-status='draft'] { | ||
| background: var(--color-lila); | ||
| color: var(--color-white); | ||
| } | ||
|
|
||
| .statusBadge[data-status='archived'] { | ||
| background: var(--color-coral); | ||
| color: var(--color-white); | ||
| } | ||
|
|
||
| .statusBadge[data-status='eliminated'] { | ||
| background: var(--color-gray); | ||
| color: var(--color-white); | ||
| } | ||
|
Comment on lines
+174
to
+200
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Renombra La regla 💡 Cambio propuesto-.statusBadge {
+.status-badge {
display: inline-block;
padding: 0.2rem 0.6rem;
border-radius: 4px;
font-size: 0.8rem;
font-weight: var(--font-weight-medium);
}
-.statusBadge[data-status='active'] {
+.status-badge[data-status='active'] {
background: var(--color-green-light);
color: var(--color-green-dark);
}
-.statusBadge[data-status='draft'] {
+.status-badge[data-status='draft'] {
background: var(--color-lila);
color: var(--color-white);
}
-.statusBadge[data-status='archived'] {
+.status-badge[data-status='archived'] {
background: var(--color-coral);
color: var(--color-white);
}
-.statusBadge[data-status='eliminated'] {
+.status-badge[data-status='eliminated'] {
background: var(--color-gray);
color: var(--color-white);
}<span className={styles['status-badge']} data-status={product.status.toLowerCase()}>🧰 Tools🪛 Stylelint (17.14.0)[error] 174-174: Expected class selector ".statusBadge" to be kebab-case (selector-class-pattern) (selector-class-pattern) [error] 182-182: Expected class selector ".statusBadge" to be kebab-case (selector-class-pattern) (selector-class-pattern) [error] 187-187: Expected class selector ".statusBadge" to be kebab-case (selector-class-pattern) (selector-class-pattern) [error] 192-192: Expected class selector ".statusBadge" to be kebab-case (selector-class-pattern) (selector-class-pattern) [error] 197-197: Expected class selector ".statusBadge" to be kebab-case (selector-class-pattern) (selector-class-pattern) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| @media (max-width: 720px) { | ||
| .header { | ||
| flex-direction: column; | ||
|
|
||
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Este módulo no pasa las reglas de Stylelint configuradas.
Ahora mismo hay errores por
selector-class-pattern(selectores en camelCase) yalpha-value-notation(0.08/0.25), así que el lint seguirá fallando hasta normalizar esos selectores y valores alpha.Also applies to: 41-41, 44-49, 57-57, 69-69, 72-72, 104-111
🧰 Tools
🪛 Stylelint (17.14.0)
[error] 11-11: Expected class selector ".backLink" to be kebab-case (selector-class-pattern)
(selector-class-pattern)
[error] 18-18: Expected class selector ".backLink" to be kebab-case (selector-class-pattern)
(selector-class-pattern)
🤖 Prompt for AI Agents
Source: Linters/SAST tools