-
Notifications
You must be signed in to change notification settings - Fork 0
chore: several agreements #17
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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |||||||||||||||||||||||
| <UInputNumber | ||||||||||||||||||||||||
| v-model="state.marketingFee" | ||||||||||||||||||||||||
| orientation="vertical" | ||||||||||||||||||||||||
| :step="0.1" | ||||||||||||||||||||||||
| size="xl" | ||||||||||||||||||||||||
| class="w-full items-center justify-center" | ||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
|
|
@@ -87,8 +88,8 @@ const { t } = useI18n() | |||||||||||||||||||||||
| const actionToast = useActionToast() | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const partnerStore = usePartnerStore() | ||||||||||||||||||||||||
| const partner = computed(() => partnerStore.partners.find((partner) => partner.activeAgreementId === agreementId)) | ||||||||||||||||||||||||
| const agreement = computed(() => partner.value?.activeAgreement) | ||||||||||||||||||||||||
| const partner = computed(() => partnerStore.partners.find((partner) => partner.legalEntity?.agreements.some((agreement) => agreement.id === agreementId))) | ||||||||||||||||||||||||
| const agreement = computed(() => partner.value?.legalEntity?.agreements.find((agreement) => agreement.id === agreementId)) | ||||||||||||||||||||||||
|
Comment on lines
+91
to
+92
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 chainVerify agreement lookup logic and consider performance optimization. The new agreement lookup logic correctly implements the transition from single active agreement to multiple agreements. However, there are a few considerations:
Consider this more efficient approach: -const partner = computed(() => partnerStore.partners.find((partner) => partner.legalEntity?.agreements.some((agreement) => agreement.id === agreementId)))
-const agreement = computed(() => partner.value?.legalEntity?.agreements.find((agreement) => agreement.id === agreementId))
+const partnerAndAgreement = computed(() => {
+ for (const partner of partnerStore.partners) {
+ const agreement = partner.legalEntity?.agreements.find(a => a.id === agreementId)
+ if (agreement) {
+ return { partner, agreement }
+ }
+ }
+ return { partner: null, agreement: null }
+})
+const partner = computed(() => partnerAndAgreement.value.partner)
+const agreement = computed(() => partnerAndAgreement.value.agreement)Please verify that all agreement lookups across the codebase handle the case where agreements might be undefined or empty arrays. 🏁 Script executed: #!/bin/bash
# Description: Check for potential null/undefined access patterns in agreement lookups
# Expected: Find all places where agreements array is accessed to ensure proper null checking
rg -A 3 -B 1 "\.agreements\." --type vue --type ts
rg -A 3 -B 1 "agreements\[" --type vue --type ts
rg -A 3 -B 1 "agreements\.find" --type vue --type ts
rg -A 3 -B 1 "agreements\.some" --type vue --type tsLength of output: 325 🏁 Script executed: #!/bin/bash
# Description: Search for all usages of `agreements` in .vue and .ts files
# to verify proper null/undefined checks around agreement lookups.
# Search for property access (e.g., partner.legalEntity.agreements)
rg -n "\.agreements" -g "*.vue" -g "*.ts" -A2 -B1
# Search for direct array indexing (e.g., agreements[0])
rg -n "agreements\[" -g "*.vue" -g "*.ts" -A2 -B1Length of output: 2147 Ensure safe and efficient agreement lookups Most components guard against missing • apps/web-app/app/components/form/UpdatePartnerAgreement.vue (91–92) Suggested fixes:
- const partner = computed(() =>
- partnerStore.partners.find(p => p.legalEntity?.agreements.some(a => a.id === agreementId))
- )
- const agreement = computed(() =>
- partner.value?.legalEntity?.agreements.find(a => a.id === agreementId)
- )
+ const partnerAndAgreement = computed(() => {
+ for (const p of partnerStore.partners) {
+ const match = p.legalEntity?.agreements?.find(a => a.id === agreementId)
+ if (match) return { partner: p, agreement: match }
+ }
+ return { partner: null, agreement: null }
+ })
+ const partner = computed(() => partnerAndAgreement.value.partner)
+ const agreement = computed(() => partnerAndAgreement.value.agreement)
- partner?.legalEntity?.agreements
+ partner?.legalEntity?.agreements ?? []This ensures you never call 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const state = ref<Partial<UpdatePartnerAgreement>>({ | ||||||||||||||||||||||||
| royalty: agreement.value?.royalty, | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,23 +23,12 @@ | |||||||||||||||||||||||
| </template> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||||||
| import { format } from 'date-fns' | ||||||||||||||||||||||||
| import { ru } from 'date-fns/locale/ru' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const { t } = useI18n() | ||||||||||||||||||||||||
| const { params } = useRoute('partner-id') | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const partnerStore = usePartnerStore() | ||||||||||||||||||||||||
| const partner = computed(() => partnerStore.partners.find((partner) => partner.id === params.id)) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const activeAgreementTo = computed(() => { | ||||||||||||||||||||||||
| if (!partner.value?.activeAgreement?.willEndAt) { | ||||||||||||||||||||||||
| return 'отсутствует' | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return `до ${format(new Date(partner.value?.activeAgreement?.willEndAt), 'd MMMM yyyy', { locale: ru })}` | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const submenuItems = computed(() => [ | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| label: t('common.partner'), | ||||||||||||||||||||||||
|
|
@@ -54,10 +43,10 @@ const submenuItems = computed(() => [ | |||||||||||||||||||||||
| badge: partner.value?.kitchens.length, | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| label: 'Договор', | ||||||||||||||||||||||||
| label: 'Договора', | ||||||||||||||||||||||||
| to: `/partner/${partner.value?.id}/agreement`, | ||||||||||||||||||||||||
| icon: 'i-lucide-scroll-text', | ||||||||||||||||||||||||
| badge: activeAgreementTo.value, | ||||||||||||||||||||||||
| badge: partner.value?.legalEntity?.agreements.length, | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
|
Comment on lines
+46
to
50
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. 🛠️ Refactor suggestion Good refactoring to plural form and count display. The changes appropriately reflect the shift from single to multiple agreements:
However, there's a potential null safety issue with - badge: partner.value?.legalEntity?.agreements.length,
+ badge: partner.value?.legalEntity?.agreements?.length ?? 0,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| label: 'Юр. лицо', | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
Potential runtime error with agreement sorting logic.
The
minimalAgreementcomputation has several potential issues:new Date(a.willEndAt ?? '')will create an invalid date ifwillEndAtis null/undefinedagreementsis emptyApply this diff to add proper error handling:
📝 Committable suggestion
🤖 Prompt for AI Agents