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

@@ -0,0 +1,53 @@
import { useQuery } from '@vue/apollo-composable';
import { MyCounterpartyProfileDocument } from '~/composables/graphql/generated';
function hasText(value: string | null | undefined) {
return Boolean(value && value.trim().length > 0);
}
export function isCounterpartyProfileComplete(profile: {
companyName?: string | null;
companyFullName?: string | null;
inn?: string | null;
legalAddress?: string | null;
bankName?: string | null;
bik?: string | null;
correspondentAccount?: string | null;
checkingAccount?: string | null;
signerFullName?: string | null;
signerPosition?: string | null;
signerBasis?: string | null;
} | null | undefined) {
if (!profile) {
return false;
}
return [
profile.companyName,
profile.companyFullName,
profile.inn,
profile.legalAddress,
profile.bankName,
profile.bik,
profile.correspondentAccount,
profile.checkingAccount,
profile.signerFullName,
profile.signerPosition,
profile.signerBasis,
].every(hasText);
}
export function useCounterpartyProfile() {
const query = useQuery(MyCounterpartyProfileDocument);
const profile = computed(() => query.result.value?.myCounterpartyProfile ?? null);
const isComplete = computed(() => isCounterpartyProfileComplete(profile.value));
return {
profile,
isComplete,
loading: query.loading,
error: query.error,
refetch: query.refetch,
};
}