Skip to content

feat: add flow item comment action#205

Merged
hmbanan666 merged 1 commit into
mainfrom
flow-comments
Oct 7, 2025
Merged

feat: add flow item comment action#205
hmbanan666 merged 1 commit into
mainfrom
flow-comments

Conversation

@hmbanan666
Copy link
Copy Markdown
Collaborator

@hmbanan666 hmbanan666 commented Oct 7, 2025

Summary by CodeRabbit

  • New Features
    • Added Agreements, Kitchens, and Partners pages (placeholder content).
    • Introduced comment submission for flow items via a drawer, with haptic feedback.
    • Updated navigation to a dynamic list with haptic feedback on click.
  • Style
    • “Viewed” avatars now wrap for better display on small screens.
    • Icons adapt to item type; avatars appear only on user posts.

@hmbanan666 hmbanan666 self-assigned this Oct 7, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 7, 2025

Walkthrough

Introduces comment creation via a Drawer on the flow item page, adds a comment form component posting to an API, updates ItemCard icon/avatar logic with a new flow item type, adjusts navigation to data-driven buttons with haptics, and adds static placeholder pages for agreements, kitchens, and partners. Updates database type definitions.

Changes

Cohort / File(s) Summary of changes
Flow item UI and comment flow
apps/atrium-telegram/app/pages/flow/[itemId]/index.vue, apps/atrium-telegram/app/components/form/CreateFlowItemComment.vue
Replaced direct message button with UDrawer hosting the new CreateFlowItemComment; added drawer state and handlers; new form component posts to /api/flow/id/{itemId}/comment, validates, updates stores, emits success/submitted, and triggers haptics.
Item card icon/avatar logic
apps/atrium-telegram/app/components/flow/ItemCard.vue
Avatar shown only for user_post with userId; non-avatar items use dynamic Lucide icon via getIconName(type) mapping (includes partner_maintenance, reports, default).
Database type update
packages/database/src/types/entities.ts
Expanded FlowItemType to include 'partner_maintenance'; reformatted union across lines.
Navigation page
apps/atrium-telegram/app/pages/navigation.vue
Replaced static title with data-driven list of UButtons sourced from a new items array; integrated useFeedback().vibrate on click.
New static pages
apps/atrium-telegram/app/pages/agreement/index.vue, apps/atrium-telegram/app/pages/kitchen/index.vue, apps/atrium-telegram/app/pages/partner/index.vue
Added template-only pages with PageContainer, SectionTitle, and placeholder content "Чуть позже".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant FlowItemPage as Flow Item Page
  participant UDrawer as Drawer
  participant Form as CreateFlowItemComment
  participant API as POST /api/flow/id/{itemId}/comment
  participant Stores as Flow/User Stores
  participant UI as UI

  User->>FlowItemPage: Click "Message" button
  FlowItemPage->>UDrawer: Open
  UDrawer->>Form: Render with itemId

  User->>Form: Enter text, Submit
  Form->>API: Send comment (Authorization)
  API-->>Form: Success/Failure

  alt Success
    Form->>Stores: Update flow/user
    Stores-->>UI: State updated
    Form-->>UDrawer: emit submitted/success
    UDrawer->>FlowItemPage: Close drawer
  else Error
    Form-->>User: Haptic error feedback
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: create flow item action #179 — Also adjusts ItemCard.vue avatar/icon logic and flow item type handling, likely tied to the new partner_maintenance type and icon mapping.

Poem

A rabbit taps a gentle beat,
A drawer slides—comment complete.
Icons swap with tidy grace,
New pages wait, a holding place.
Types expand, the flow feels right—
I twitch my nose, approve the site. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly reflects the primary feature added by this pull request, namely the flow item comment action, and uses concise, clear phrasing aligned with conventional commit style.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch flow-comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 7, 2025

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
apps/atrium-telegram/app/pages/partner/index.vue (1)

1-7: Consider adding i18n for hardcoded text.

The title "Партнеры" and placeholder text "Чуть позже" are hardcoded in Russian. For consistency with other parts of the app (e.g., line 27 in CreateFlowItemComment.vue uses $t('common.send')), consider extracting these strings to translation files.

apps/atrium-telegram/app/pages/agreement/index.vue (1)

1-7: Consider adding i18n for hardcoded text.

Similar to the partner page, the title "Реестр договоров" and placeholder text "Чуть позже" are hardcoded. Consider using translation keys for consistency across the application.

apps/atrium-telegram/app/pages/kitchen/index.vue (1)

1-7: Consider adding i18n for hardcoded text.

Consistent with the other placeholder pages, the title "Кухни" and placeholder text "Чуть позже" should be extracted to translation files for maintainability.

apps/atrium-telegram/app/pages/navigation.vue (2)

25-44: Use const instead of ref for static data.

The items array is static and never changes at runtime. Using ref() adds unnecessary reactivity overhead. Consider using a plain const instead:

-const items = ref([
+const items = [
   {
     label: 'Реестр договоров',
     to: '/agreement',
     icon: 'i-lucide-list-checks',
     onClick: () => vibrate(),
   },
   // ...
-])
+]

25-44: Extract hardcoded labels to i18n.

Navigation labels are hardcoded in Russian. For consistency and maintainability, consider using translation keys (e.g., $t('navigation.agreements'), $t('navigation.partners'), $t('navigation.kitchens')).

apps/atrium-telegram/app/components/form/CreateFlowItemComment.vue (1)

49-72: Consider adding user-facing error feedback.

The error handling logs to console and triggers haptic feedback, but doesn't display an error message to the user. Consider adding a toast notification or inline error display to inform users when comment submission fails.

Example:

+const toast = useToast()
+
 async function onSubmit(event: FormSubmitEvent<CreateFlowItemComment>) {
   emit('submitted')
 
   try {
     await $fetch(`/api/flow/id/${itemId}/comment`, {
       method: 'POST',
       headers: {
         Authorization: `tma ${userStore.initDataRaw}`,
       },
       body: event.data,
     })
 
     await Promise.all([
       flowStore.update(),
       userStore.update(),
     ])
 
     vibrate('success')
     emit('success')
   } catch (error) {
     console.error(error)
+    toast.add({
+      title: 'Ошибка при отправке комментария',
+      color: 'red',
+    })
     vibrate('error')
   }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d23bc1c and a7eaa25.

📒 Files selected for processing (8)
  • apps/atrium-telegram/app/components/flow/ItemCard.vue (2 hunks)
  • apps/atrium-telegram/app/components/form/CreateFlowItemComment.vue (1 hunks)
  • apps/atrium-telegram/app/pages/agreement/index.vue (1 hunks)
  • apps/atrium-telegram/app/pages/flow/[itemId]/index.vue (3 hunks)
  • apps/atrium-telegram/app/pages/kitchen/index.vue (1 hunks)
  • apps/atrium-telegram/app/pages/navigation.vue (1 hunks)
  • apps/atrium-telegram/app/pages/partner/index.vue (1 hunks)
  • packages/database/src/types/entities.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (6)
apps/atrium-telegram/app/components/flow/ItemCard.vue (2)

63-75: LGTM! Clean icon mapping implementation.

The getIconName function provides clear, type-safe icon mapping for all flow item types, including the newly added partner_maintenance. The switch statement handles all cases with an appropriate default fallback.


5-5: Avatar visibility correctly restricted to user posts.

The updated condition item.userId && item.type === 'user_post' ensures avatars only render for user-authored posts, which aligns with the new partner_maintenance type that may not have an associated userId.

packages/database/src/types/entities.ts (1)

34-37: LGTM! Type expansion aligns with UI updates.

The addition of 'partner_maintenance' to FlowItemType is properly integrated with the icon mapping in ItemCard.vue (line 67-68) and follows the existing type union pattern.

apps/atrium-telegram/app/pages/flow/[itemId]/index.vue (2)

64-83: LGTM! Clean Drawer integration for comment submission.

The Drawer pattern effectively wraps the comment form, and the dual event handlers (@submitted and @success) ensure the drawer closes appropriately regardless of the submission outcome. The button properly triggers both vibration and drawer opening.


109-109: Clean state management for drawer visibility.

The isDrawerOpened ref provides straightforward, single-purpose state control for the Drawer component.

apps/atrium-telegram/app/components/form/CreateFlowItemComment.vue (1)

1-30: LGTM! Clean form structure with proper validation.

The form implementation follows Vue best practices with schema-based validation, proper state management, and appropriate UX (disabled submit button when text is empty). The integration with the Drawer pattern via emitted events is well-designed.

@hmbanan666 hmbanan666 merged commit 0a65327 into main Oct 7, 2025
8 checks passed
@hmbanan666 hmbanan666 deleted the flow-comments branch October 7, 2025 13:18
This was referenced Oct 8, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant