feat(profile): add counterparty card with dadata search and cart gating

This commit is contained in:
Ruslan Bakiev
2026-04-02 16:47:27 +07:00
parent f4a4b41dd5
commit d72de0f8c3
10 changed files with 879 additions and 41 deletions

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import { useMutation } from '@vue/apollo-composable';
import { SubmitCalculationOrderDocument } from '~/composables/graphql/generated';
import { useCounterpartyProfile } from '~/composables/useCounterpartyProfile';
const productName = ref('');
const quantity = ref(1);
@@ -12,6 +13,7 @@ const { mutate, loading, onDone, onError } = useMutation(SubmitCalculationOrderD
const success = ref('');
const errorMessage = ref('');
const calculatedVolume = computed(() => Number(quantity.value) * Number(width.value) * Number(thickness.value));
const { isComplete: isCounterpartyComplete, loading: counterpartyLoading } = useCounterpartyProfile();
onDone((result) => {
success.value = `Заявка ${result.data?.submitCalculationOrder.code} отправлена`;
@@ -24,6 +26,12 @@ onError((error) => {
});
function submit() {
if (!isCounterpartyComplete.value) {
errorMessage.value = 'Сначала заполните карточку контрагента в профиле.';
success.value = '';
return;
}
mutate({
input: {
productName: productName.value,
@@ -48,6 +56,14 @@ function submit() {
<div class="mx-auto max-w-4xl rounded-[30px] p-1 shadow-[0_26px_60px_rgba(13,133,74,0.18)]">
<div class="surface-card grid gap-6 rounded-[26px] p-5 md:grid-cols-[1.45fr_1fr] md:p-6">
<div class="space-y-3">
<div v-if="counterpartyLoading.value" class="alert">
Проверяем карточку контрагента...
</div>
<div v-else-if="!isCounterpartyComplete" class="alert alert-warning">
Для оформления заявки заполните карточку контрагента в
<NuxtLink to="/profile" class="link link-hover font-semibold">профиле</NuxtLink>.
</div>
<label class="form-control">
<span class="label-text font-semibold text-[#194631]">Название позиции</span>
<input v-model="productName" type="text" class="input input-bordered border-[#d0e8d8] bg-white/80">
@@ -70,7 +86,7 @@ function submit() {
<input v-model="color" type="text" class="input input-bordered border-[#d0e8d8] bg-white/80">
</label>
</div>
<button class="btn border-0 bg-[#139957] text-white hover:bg-[#0d854a]" :disabled="loading" @click="submit">
<button class="btn border-0 bg-[#139957] text-white hover:bg-[#0d854a]" :disabled="loading || counterpartyLoading.value || !isCounterpartyComplete" @click="submit">
{{ loading ? 'Отправляем' : 'Отправить менеджеру' }}
</button>
</div>