-
Notifications
You must be signed in to change notification settings - Fork 0
chore: epic comment add action rework #113
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
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <template> | ||
| <div class="p-4 tg-bg-section group/section space-y-3.5 rounded-lg"> | ||
| <div class="relative p-4 tg-bg-section group/section space-y-3.5 rounded-lg"> | ||
| <slot /> | ||
| </div> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,73 @@ | ||
| <template> | ||
| <UCard | ||
| variant="subtle" | ||
| class="mt-auto bg-elevated/25" | ||
| <UForm | ||
| :validate="createValidator(createEpicCommentSchema)" | ||
| :state="state" | ||
|
Comment on lines
+2
to
+4
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. 💡 Verification agent 🧩 Analysis chainMissing/implicit
Run to locate its definition and usages: If not auto-imported, add the proper import path used elsewhere in the project. 🏁 Script executed: #!/bin/bash
# Find a definition/export of createValidator
rg -nP 'export\s+(?:const|function)\s+createValidator\b|createValidator:\s*' -C2
# Check for a Nuxt auto-import declaration
rg -nP 'autoImports|imports:\s*\{[^}]*imports' -g '!**/node_modules/**' -C3
# Where else is it used (to infer import style)
rg -nP '\bcreateValidator\s*\(' -g '!**/node_modules/**' -C2Length of output: 19492 Add missing import { createValidator } from '~/utils/ui'
🤖 Prompt for AI Agents |
||
| class="flex flex-col gap-3" | ||
| @submit="onSubmit" | ||
| > | ||
| <form | ||
| class="flex flex-col gap-4" | ||
| @submit.prevent="onCommentSubmit" | ||
| > | ||
| <UFormField label="Комментарий" name="text"> | ||
| <UTextarea | ||
| v-model="text" | ||
| color="neutral" | ||
| variant="none" | ||
| size="xl" | ||
| required | ||
| autoresize | ||
| v-model="state.text" | ||
| placeholder="Напишите свою мысль..." | ||
| :rows="3" | ||
| :disabled="loading" | ||
| autoresize | ||
| size="xl" | ||
| class="w-full" | ||
| :ui="{ base: 'p-1' }" | ||
| /> | ||
| </UFormField> | ||
|
|
||
| <div class="flex items-center justify-end gap-2"> | ||
| <UButton | ||
| type="submit" | ||
| color="secondary" | ||
| size="md" | ||
| :loading="loading" | ||
| :disabled="!text" | ||
| label="Добавить комментарий" | ||
| icon="i-lucide-send" | ||
| :ui="{ | ||
| base: 'px-3 rounded-full', | ||
| label: 'font-medium', | ||
| }" | ||
| /> | ||
| </div> | ||
| </form> | ||
| </UCard> | ||
| <UButton | ||
| type="submit" | ||
| variant="solid" | ||
| color="secondary" | ||
| size="xl" | ||
| icon="i-lucide-send" | ||
| block | ||
| class="mt-3" | ||
| :disabled="!state.text" | ||
| :label="$t('common.send')" | ||
| /> | ||
| </UForm> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import type { CreateEpicComment } from '#shared/services/epic' | ||
| import type { FormSubmitEvent } from '@nuxt/ui' | ||
| import { createEpicCommentSchema } from '#shared/services/epic' | ||
|
|
||
| const { epicId } = defineProps<{ epicId: string }>() | ||
|
|
||
| const emit = defineEmits(['success', 'submitted']) | ||
|
|
||
| const { vibrate } = useFeedback() | ||
| const userStore = useUserStore() | ||
| const epicStore = useEpicStore() | ||
|
|
||
| const text = ref('') | ||
| const loading = ref(false) | ||
|
|
||
| async function onCommentSubmit() { | ||
| const trimmed = text.value.trim() | ||
| if (!trimmed) { | ||
| return | ||
| } | ||
| const state = ref<Partial<CreateEpicComment>>({ | ||
| text: undefined, | ||
| }) | ||
|
|
||
| loading.value = true | ||
| async function onSubmit(event: FormSubmitEvent<CreateEpicComment>) { | ||
| emit('submitted') | ||
|
|
||
| try { | ||
| await epicStore.addComment(epicId, trimmed) | ||
| text.value = '' | ||
| await $fetch(`/api/epic/id/${epicId}/comment`, { | ||
| method: 'POST', | ||
| headers: { | ||
| Authorization: `tma ${userStore.initDataRaw}`, | ||
| }, | ||
| body: event.data, | ||
| }) | ||
|
|
||
| await Promise.all([ | ||
| epicStore.update(), | ||
| userStore.update(), | ||
| ]) | ||
|
|
||
| vibrate('success') | ||
| } catch (e) { | ||
| console.error(e) | ||
| emit('success') | ||
| } catch (error) { | ||
| console.error(error) | ||
| vibrate('error') | ||
| } finally { | ||
| loading.value = false | ||
| } | ||
| } | ||
| </script> | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||||||||
| <template> | ||||||||||||||||||||
| <UModal :title="$t('app.create.epic-comment.title')"> | ||||||||||||||||||||
| <template #body> | ||||||||||||||||||||
| <FormCreateEpicComment | ||||||||||||||||||||
| :epic-id="epicId" | ||||||||||||||||||||
| @submitted="overlay.closeAll" | ||||||||||||||||||||
| @success="overlay.closeAll" | ||||||||||||||||||||
| /> | ||||||||||||||||||||
|
Comment on lines
+4
to
+8
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. Don’t close the modal on submit start; close only on success. Closing on Apply this diff: <FormCreateEpicComment
:epic-id="epicId"
- @submitted="overlay.closeAll"
@success="overlay.closeAll"
/>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| </template> | ||||||||||||||||||||
| </UModal> | ||||||||||||||||||||
| </template> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||
| defineProps<{ | ||||||||||||||||||||
| epicId: string | ||||||||||||||||||||
| }>() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const overlay = useOverlay() | ||||||||||||||||||||
| </script> | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,10 @@ | |||||||||||||||||
| "button": "Создать эпик", | ||||||||||||||||||
| "title": "Создание эпика" | ||||||||||||||||||
| }, | ||||||||||||||||||
| "epic-comment": { | ||||||||||||||||||
| "button": "Создать комментарий", | ||||||||||||||||||
| "title": "Создание комментария" | ||||||||||||||||||
| }, | ||||||||||||||||||
|
Comment on lines
+43
to
+46
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. Fix Cyrillic letter in “комментарий” (combining mark currently used). The button label uses "комментарий" (и + combining breve). Replace with the correct single character "й". Apply this diff: "epic-comment": {
- "button": "Создать комментарий",
+ "button": "Создать комментарий",
"title": "Создание комментария"
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| "beacon": { | ||||||||||||||||||
| "button": "Создать маяк", | ||||||||||||||||||
| "title": "Создание маяка" | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,7 @@ export default defineEventHandler(async (event) => { | |||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const comment = await repository.epic.createComment({ | ||||||||||||||||||||||||||||||||||
| ...data, | ||||||||||||||||||||||||||||||||||
| text: data.text.trim(), | ||||||||||||||||||||||||||||||||||
| userId: event.context.user.id, | ||||||||||||||||||||||||||||||||||
| epicId, | ||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
21
to
25
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. Prevent whitespace-only comments (trim happens after validation). If the schema allows a single character, strings like " " will pass validation and be saved as empty after trim. Trim first and reject empty. Apply this diff: - const comment = await repository.epic.createComment({
- text: data.text.trim(),
- userId: event.context.user.id,
- epicId,
- })
+ const text = data.text.trim()
+ if (!text) {
+ throw createError({ statusCode: 400, message: 'Text is required' })
+ }
+ const comment = await repository.epic.createComment({
+ text,
+ userId: event.context.user.id,
+ epicId,
+ })📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
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.
Add type="button" to prevent unintended form submissions
Without an explicit type, buttons default to submit inside forms.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents
🛠️ Refactor suggestion
Restore visible focus styles; replace outline-0 with a custom focus-visible ring (and smooth the scale animation)
outline-0removes the default focus indicator; add an explicit focus style. Also addtransition-transformsoactive:scale-95animates.Apply this diff:
If you have design tokens (e.g.,
tg-colors), swapindigo-500/offsets accordingly.🤖 Prompt for AI Agents