-
Notifications
You must be signed in to change notification settings - Fork 0
feat: flow items on web atrium #211
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/atrium-telegram/server/api/flow/id/[itemId]/comment.post.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| <template> | ||
| <UCard> | ||
| <div class="flex flex-col gap-3"> | ||
| <div class="flex flex-row gap-3 items-center"> | ||
| <UAvatar | ||
| v-if="item.userId && item.type === 'user_post'" | ||
| :src="userAvatarUrl" | ||
| class="size-8" | ||
| /> | ||
| <UIcon | ||
| v-else | ||
| :name="getIconName(item.type)" | ||
| class="size-8 text-secondary" | ||
| /> | ||
|
|
||
| <div v-if="!isViewed" class="flex flex-row items-center gap-1.5 text-error"> | ||
| <UIcon | ||
| name="i-lucide-pointer" | ||
| class="size-8 motion-translate-y-loop-25 motion-preset-seesaw motion-duration-2000" | ||
| /> | ||
| <p class="max-w-22 text-sm/4 font-bold"> | ||
| Не просмотрено | ||
| </p> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="flex flex-col gap-2"> | ||
| <p class="text-sm/4 md:text-lg/6 font-bold whitespace-pre-wrap"> | ||
| {{ item.title }} | ||
| </p> | ||
|
|
||
| <p class="text-base/5 whitespace-pre-wrap"> | ||
| {{ item.description }} | ||
| </p> | ||
| </div> | ||
|
|
||
| <div v-if="!isViewed"> | ||
| <UButton | ||
| variant="solid" | ||
| color="secondary" | ||
| size="lg" | ||
| icon="i-lucide-check" | ||
| label="Отметить как просмотренное" | ||
| class="w-full justify-center font-bold" | ||
| @click="flowStore.addView(item.id)" | ||
| /> | ||
| </div> | ||
|
|
||
| <div class="flex justify-between items-center"> | ||
| <div class="flex flex-row gap-4"> | ||
| <div class="flex flex-row gap-1.5 items-center text-sm text-muted"> | ||
| <UIcon name="i-lucide-message-circle" class="size-5" /> | ||
| <p>{{ item?.comments.length }}</p> | ||
| </div> | ||
| </div> | ||
|
|
||
| <time | ||
| :datetime="item.createdAt" | ||
| class="text-sm text-muted" | ||
| v-text="format(new Date(item.createdAt), 'd MMMM yyyy в HH:mm', { locale: ru })" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </UCard> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { format } from 'date-fns' | ||
| import { ru } from 'date-fns/locale' | ||
|
|
||
| const { item } = defineProps<{ | ||
| item: FlowItemWithData | ||
| }>() | ||
|
|
||
| const userStore = useUserStore() | ||
| const flowStore = useFlowStore() | ||
| const isViewed = computed(() => item?.views.some((view) => view.userId === useUserStore().id)) | ||
| const userAvatarUrl = computed(() => userStore.users.find((user) => user.id === item.userId)?.avatarUrl ?? undefined) | ||
|
|
||
| function getIconName(type: FlowItemWithData['type']): string { | ||
| switch (type) { | ||
| case 'user_post': | ||
| return 'i-lucide-square-user-round' | ||
| case 'partner_maintenance': | ||
| return 'i-lucide-user' | ||
| case 'daily_task_report': | ||
| case 'weekly_task_report': | ||
| return 'i-lucide-clipboard-check' | ||
| default: | ||
| return 'i-lucide-clipboard' | ||
| } | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import type { FlowItem, FlowItemComment, FlowItemView } from '@roll-stack/database' | ||
|
|
||
| export type FlowItemWithData = FlowItem & { | ||
| comments: FlowItemComment[] | ||
| views: FlowItemView[] | ||
| } | ||
|
|
||
| export const useFlowStore = defineStore('flow', () => { | ||
| const items = ref<FlowItemWithData[]>([]) | ||
|
|
||
| const nowViewedItemsCount = computed(() => items.value.filter((item) => !item.views.some((view) => view.userId === useUserStore().id)).length) | ||
|
|
||
| async function update() { | ||
| try { | ||
| const data = await $fetch('/api/flow/list') | ||
| if (!data) { | ||
| return | ||
| } | ||
|
|
||
| items.value = data | ||
| } catch (error) { | ||
| if (error instanceof Error) { | ||
| if (error.message.includes('401')) { | ||
| // No | ||
| } | ||
| if (error.message.includes('404')) { | ||
| // Not found | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async function addView(itemId: string) { | ||
| try { | ||
| await $fetch(`/api/flow/id/${itemId}/view`, { | ||
| method: 'POST', | ||
| }) | ||
|
|
||
| await update() | ||
| } catch (error) { | ||
| if (error instanceof Error) { | ||
| if (error.message.includes('401')) { | ||
| // No | ||
| } | ||
| if (error.message.includes('404')) { | ||
| // Not found | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| items, | ||
|
|
||
| nowViewedItemsCount, | ||
|
|
||
| update, | ||
| addView, | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { db } from '@roll-stack/database' | ||
| import { createFlowItemCommentSchema } from '@roll-stack/schema' | ||
| import { type } from 'arktype' | ||
|
|
||
| export default defineEventHandler(async (event) => { | ||
| try { | ||
| const itemId = getRouterParam(event, 'itemId') | ||
| if (!itemId) { | ||
| throw createError({ | ||
| statusCode: 400, | ||
| message: 'Id is required', | ||
| }) | ||
| } | ||
|
|
||
| const body = await readBody(event) | ||
| const data = createFlowItemCommentSchema(body) | ||
| if (data instanceof type.errors) { | ||
| throw data | ||
| } | ||
|
|
||
| // Guards: | ||
| // If not exist | ||
| const item = await db.flow.findItem(itemId) | ||
| if (!item) { | ||
| throw createError({ | ||
| statusCode: 404, | ||
| message: 'Item not found', | ||
| }) | ||
| } | ||
|
|
||
| await db.flow.createItemComment({ | ||
| text: data.text, | ||
| itemId, | ||
| userId: event.context.user.id, | ||
|
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. Validate user context existence before access.
Add authentication guard: + if (!event.context.user) {
+ throw createError({
+ statusCode: 401,
+ message: 'Authentication required',
+ })
+ }
+
await db.flow.createItemComment({
text: data.text,
itemId,
userId: event.context.user.id,
})🤖 Prompt for AI Agents |
||
| }) | ||
|
|
||
| return { ok: true } | ||
| } catch (error) { | ||
| throw errorResolver(error) | ||
| } | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
Verify arktype dependency status.
The dependency addition is correct. However, the AI summary mentions "removed the arktype catalog dependency," but arktype is still imported and used in the server API files (e.g.,
import { type } from 'arktype'in comment.post.ts). Ensure arktype remains as a dependency if it's still being used.🏁 Script executed:
Length of output: 5237
Declare arktype in package.json
Arktype is imported across multiple server and shared files but missing from apps/web-app/package.json dependencies—add
"arktype": "<appropriate version>".🤖 Prompt for AI Agents