Add KYC profile integration and SupplierInfoBlock component
Some checks failed
Build Docker Image / build (push) Failing after 2m51s
Some checks failed
Build Docker Image / build (push) Failing after 2m51s
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
:currency="getOfferData(option.sourceUuid)?.currency"
|
||||
:unit="getOfferData(option.sourceUuid)?.unit"
|
||||
:stages="getRouteStages(option)"
|
||||
:kyc-profile-uuid="getKycProfileUuid(option.sourceUuid)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -64,7 +65,7 @@
|
||||
<script setup lang="ts">
|
||||
import { GetOffersByHubDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import type { RouteStageItem } from '~/components/RouteStagesList.vue'
|
||||
import { GetOfferDocument } from '~/composables/graphql/public/exchange-generated'
|
||||
import { GetOfferDocument, GetSupplierProfileByTeamDocument } from '~/composables/graphql/public/exchange-generated'
|
||||
|
||||
const route = useRoute()
|
||||
const searchStore = useSearchStore()
|
||||
@@ -76,6 +77,8 @@ const quantity = computed(() => (route.query.quantity as string) || (searchStore
|
||||
|
||||
// Offer data for prices
|
||||
const offersData = ref<Map<string, any>>(new Map())
|
||||
// Supplier data for KYC profile UUID (by team_uuid)
|
||||
const suppliersData = ref<Map<string, any>>(new Map())
|
||||
|
||||
const summaryTitle = computed(() => `${productName.value} → ${locationName.value}`)
|
||||
const summaryMeta = computed(() => {
|
||||
@@ -163,26 +166,57 @@ const getOfferData = (uuid?: string | null) => {
|
||||
return offersData.value.get(uuid)
|
||||
}
|
||||
|
||||
// Get KYC profile UUID by offer UUID
|
||||
const getKycProfileUuid = (offerUuid?: string | null) => {
|
||||
if (!offerUuid) return null
|
||||
const offer = offersData.value.get(offerUuid)
|
||||
if (!offer?.teamUuid) return null
|
||||
const supplier = suppliersData.value.get(offer.teamUuid)
|
||||
return supplier?.kycProfileUuid || null
|
||||
}
|
||||
|
||||
// Load offer details for prices
|
||||
const loadOfferDetails = async (options: ProductRouteOption[]) => {
|
||||
if (options.length === 0) {
|
||||
offersData.value.clear()
|
||||
suppliersData.value.clear()
|
||||
return
|
||||
}
|
||||
|
||||
const newOffersData = new Map<string, any>()
|
||||
const newSuppliersData = new Map<string, any>()
|
||||
const teamUuidsToLoad = new Set<string>()
|
||||
|
||||
// First, load all offers
|
||||
await Promise.all(options.map(async (option) => {
|
||||
if (!option.sourceUuid) return
|
||||
try {
|
||||
const data = await execute(GetOfferDocument, { uuid: option.sourceUuid }, 'public', 'exchange')
|
||||
if (data?.getOffer) {
|
||||
newOffersData.set(option.sourceUuid, data.getOffer)
|
||||
if (data.getOffer.teamUuid) {
|
||||
teamUuidsToLoad.add(data.getOffer.teamUuid)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading offer:', option.sourceUuid, error)
|
||||
}
|
||||
}))
|
||||
|
||||
// Then, load supplier profiles for all team UUIDs
|
||||
await Promise.all([...teamUuidsToLoad].map(async (teamUuid) => {
|
||||
try {
|
||||
const data = await execute(GetSupplierProfileByTeamDocument, { teamUuid }, 'public', 'exchange')
|
||||
if (data?.getSupplierProfileByTeam) {
|
||||
newSuppliersData.set(teamUuid, data.getSupplierProfileByTeam)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading supplier:', teamUuid, error)
|
||||
}
|
||||
}))
|
||||
|
||||
offersData.value = newOffersData
|
||||
suppliersData.value = newSuppliersData
|
||||
}
|
||||
|
||||
// Watch for route options and load offers
|
||||
|
||||
70
app/components/SupplierInfoBlock.vue
Normal file
70
app/components/SupplierInfoBlock.vue
Normal file
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<div v-if="kycProfileUuid && companyData" class="space-y-2">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="badge badge-outline badge-sm">{{ companyData.companyType || 'Компания' }}</span>
|
||||
<span v-if="companyData.registrationYear" class="text-xs text-base-content/60">
|
||||
с {{ companyData.registrationYear }} г.
|
||||
</span>
|
||||
<span v-if="companyData.isActive" class="badge badge-success badge-xs">Активна</span>
|
||||
</div>
|
||||
<div v-if="companyData.sourcesCount" class="text-xs text-base-content/60">
|
||||
{{ companyData.sourcesCount }} {{ pluralize(companyData.sourcesCount, 'источник', 'источника', 'источников') }} данных
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="kycProfileUuid && pending" class="text-xs text-base-content/60">
|
||||
Загрузка данных...
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { GetKycProfileTeaserDocument } from '~/composables/graphql/public/kyc-generated'
|
||||
|
||||
const props = defineProps<{
|
||||
kycProfileUuid?: string | null
|
||||
}>()
|
||||
|
||||
const { execute } = useGraphQL()
|
||||
|
||||
const companyData = ref<{
|
||||
companyType?: string | null
|
||||
registrationYear?: number | null
|
||||
isActive?: boolean | null
|
||||
sourcesCount?: number | null
|
||||
} | null>(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const loadCompanyData = async () => {
|
||||
if (!props.kycProfileUuid) return
|
||||
pending.value = true
|
||||
try {
|
||||
const data = await execute(
|
||||
GetKycProfileTeaserDocument,
|
||||
{ profileUuid: props.kycProfileUuid },
|
||||
'public',
|
||||
'kyc'
|
||||
)
|
||||
companyData.value = data?.companyTeaserByProfile || null
|
||||
} catch (error) {
|
||||
console.error('Error loading company data:', error)
|
||||
} finally {
|
||||
pending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.kycProfileUuid, (uuid) => {
|
||||
if (uuid) {
|
||||
loadCompanyData()
|
||||
} else {
|
||||
companyData.value = null
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
const pluralize = (n: number, one: string, few: string, many: string) => {
|
||||
const mod10 = n % 10
|
||||
const mod100 = n % 100
|
||||
if (mod10 === 1 && mod100 !== 11) return one
|
||||
if (mod10 >= 2 && mod10 <= 4 && (mod100 < 10 || mod100 >= 20)) return few
|
||||
return many
|
||||
}
|
||||
</script>
|
||||
@@ -11,6 +11,9 @@
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<!-- Supplier info -->
|
||||
<SupplierInfoBlock v-if="kycProfileUuid" :kyc-profile-uuid="kycProfileUuid" class="mb-3" />
|
||||
|
||||
<!-- Route stepper -->
|
||||
<RouteStepper
|
||||
v-if="stages.length > 0"
|
||||
@@ -33,6 +36,7 @@ const props = withDefaults(defineProps<{
|
||||
stages?: RouteStage[]
|
||||
startName?: string
|
||||
endName?: string
|
||||
kycProfileUuid?: string | null
|
||||
}>(), {
|
||||
stages: () => []
|
||||
})
|
||||
|
||||
@@ -15,6 +15,7 @@ const RESOURCE_MAP: Record<Api, string> = {
|
||||
const CLIENT_MAP: Record<string, string> = {
|
||||
'public:exchange': 'default',
|
||||
'public:geo': 'publicGeo',
|
||||
'public:kyc': 'publicKyc',
|
||||
'user:teams': 'teamsUser',
|
||||
'user:kyc': 'kycUser',
|
||||
'team:teams': 'teamsTeam',
|
||||
|
||||
Reference in New Issue
Block a user