+
+
+
-
- {request.receiver.name || request.receiver.fullName}
-
-
ИНН: {request.receiver.inn}
- {request.message && (
-
"{request.message}"
- )}
-
-
-
-
{formatDate(request.createdAt)}
+
+
+ {request.receiver.name || request.receiver.fullName}
+
+
+
+ {request.receiver.type === 'FULFILLMENT' ? 'Фулфилмент' :
+ request.receiver.type === 'SELLER' ? 'Селлер' :
+ request.receiver.type === 'LOGIST' ? 'Логистика' :
+ request.receiver.type === 'WHOLESALE' ? 'Оптовик' :
+ request.receiver.type}
+
+
+ {request.status === 'PENDING' ? 'Ожидает ответа' : request.status === 'REJECTED' ? 'Отклонено' : request.status}
+
+
+
+
+
+
ИНН: {request.receiver.inn}
+ {request.receiver.address && (
+
+ {request.receiver.address}
+
+ )}
+ {request.message && (
+
+ )}
+
+ Отправлено {formatDate(request.createdAt)}
-
- {request.status === 'PENDING' ? 'Ожидает' : request.status === 'REJECTED' ? 'Отклонено' : request.status}
-
@@ -308,13 +362,13 @@ export function MarketCounterparties() {
size="sm"
variant="outline"
onClick={() => handleCancelRequest(request.id)}
- className="bg-red-500/20 hover:bg-red-500/30 text-red-300 border-red-500/30 cursor-pointer ml-4"
+ className="bg-red-500/20 hover:bg-red-500/30 text-red-300 border-red-500/30 cursor-pointer w-full"
>
-
+ Отменить заявку
)}
-
+
))}
)}
diff --git a/src/components/market/market-fulfillment.tsx b/src/components/market/market-fulfillment.tsx
index 0a44a92..7fd492a 100644
--- a/src/components/market/market-fulfillment.tsx
+++ b/src/components/market/market-fulfillment.tsx
@@ -6,7 +6,7 @@ import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Search, Package } from 'lucide-react'
import { OrganizationCard } from './organization-card'
-import { SEARCH_ORGANIZATIONS } from '@/graphql/queries'
+import { SEARCH_ORGANIZATIONS, GET_INCOMING_REQUESTS, GET_OUTGOING_REQUESTS } from '@/graphql/queries'
import { SEND_COUNTERPARTY_REQUEST } from '@/graphql/mutations'
interface Organization {
@@ -21,6 +21,9 @@ interface Organization {
createdAt: string
users?: Array<{ id: string, avatar?: string }>
isCounterparty?: boolean
+ isCurrentUser?: boolean
+ hasOutgoingRequest?: boolean
+ hasIncomingRequest?: boolean
}
export function MarketFulfillment() {
@@ -31,9 +34,15 @@ export function MarketFulfillment() {
})
const [sendRequest, { loading: sendingRequest }] = useMutation(SEND_COUNTERPARTY_REQUEST, {
- onCompleted: () => {
- refetch()
- }
+ refetchQueries: [
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'SELLER' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'FULFILLMENT' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'LOGIST' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'WHOLESALE' } },
+ { query: GET_OUTGOING_REQUESTS },
+ { query: GET_INCOMING_REQUESTS }
+ ],
+ awaitRefetchQueries: true
})
const handleSearch = () => {
@@ -44,7 +53,7 @@ export function MarketFulfillment() {
try {
await sendRequest({
variables: {
- receiverId: organizationId,
+ organizationId: organizationId,
message: message || 'Заявка на добавление в контрагенты'
}
})
diff --git a/src/components/market/market-logistics.tsx b/src/components/market/market-logistics.tsx
index 7199bac..55df860 100644
--- a/src/components/market/market-logistics.tsx
+++ b/src/components/market/market-logistics.tsx
@@ -6,7 +6,7 @@ import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Search, Truck } from 'lucide-react'
import { OrganizationCard } from './organization-card'
-import { SEARCH_ORGANIZATIONS } from '@/graphql/queries'
+import { SEARCH_ORGANIZATIONS, GET_INCOMING_REQUESTS, GET_OUTGOING_REQUESTS } from '@/graphql/queries'
import { SEND_COUNTERPARTY_REQUEST } from '@/graphql/mutations'
interface Organization {
@@ -21,6 +21,9 @@ interface Organization {
createdAt: string
users?: Array<{ id: string, avatar?: string }>
isCounterparty?: boolean
+ isCurrentUser?: boolean
+ hasOutgoingRequest?: boolean
+ hasIncomingRequest?: boolean
}
export function MarketLogistics() {
@@ -31,9 +34,15 @@ export function MarketLogistics() {
})
const [sendRequest, { loading: sendingRequest }] = useMutation(SEND_COUNTERPARTY_REQUEST, {
- onCompleted: () => {
- refetch()
- }
+ refetchQueries: [
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'SELLER' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'FULFILLMENT' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'LOGIST' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'WHOLESALE' } },
+ { query: GET_OUTGOING_REQUESTS },
+ { query: GET_INCOMING_REQUESTS }
+ ],
+ awaitRefetchQueries: true
})
const handleSearch = () => {
@@ -44,7 +53,7 @@ export function MarketLogistics() {
try {
await sendRequest({
variables: {
- receiverId: organizationId,
+ organizationId: organizationId,
message: message || 'Заявка на добавление в контрагенты'
}
})
diff --git a/src/components/market/market-sellers.tsx b/src/components/market/market-sellers.tsx
index 3d0d5b9..a8abecc 100644
--- a/src/components/market/market-sellers.tsx
+++ b/src/components/market/market-sellers.tsx
@@ -6,7 +6,7 @@ import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Search, ShoppingCart } from 'lucide-react'
import { OrganizationCard } from './organization-card'
-import { SEARCH_ORGANIZATIONS } from '@/graphql/queries'
+import { SEARCH_ORGANIZATIONS, GET_INCOMING_REQUESTS, GET_OUTGOING_REQUESTS } from '@/graphql/queries'
import { SEND_COUNTERPARTY_REQUEST } from '@/graphql/mutations'
interface Organization {
@@ -21,6 +21,9 @@ interface Organization {
createdAt: string
users?: Array<{ id: string, avatar?: string }>
isCounterparty?: boolean
+ isCurrentUser?: boolean
+ hasOutgoingRequest?: boolean
+ hasIncomingRequest?: boolean
}
export function MarketSellers() {
@@ -31,9 +34,15 @@ export function MarketSellers() {
})
const [sendRequest, { loading: sendingRequest }] = useMutation(SEND_COUNTERPARTY_REQUEST, {
- onCompleted: () => {
- refetch()
- }
+ refetchQueries: [
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'SELLER' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'FULFILLMENT' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'LOGIST' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'WHOLESALE' } },
+ { query: GET_OUTGOING_REQUESTS },
+ { query: GET_INCOMING_REQUESTS }
+ ],
+ awaitRefetchQueries: true
})
const handleSearch = () => {
@@ -44,7 +53,7 @@ export function MarketSellers() {
try {
await sendRequest({
variables: {
- receiverId: organizationId,
+ organizationId: organizationId,
message: message || 'Заявка на добавление в контрагенты'
}
})
diff --git a/src/components/market/market-wholesale.tsx b/src/components/market/market-wholesale.tsx
index 1bbbe80..69e93e2 100644
--- a/src/components/market/market-wholesale.tsx
+++ b/src/components/market/market-wholesale.tsx
@@ -6,7 +6,7 @@ import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Search, Boxes } from 'lucide-react'
import { OrganizationCard } from './organization-card'
-import { SEARCH_ORGANIZATIONS } from '@/graphql/queries'
+import { SEARCH_ORGANIZATIONS, GET_INCOMING_REQUESTS, GET_OUTGOING_REQUESTS } from '@/graphql/queries'
import { SEND_COUNTERPARTY_REQUEST } from '@/graphql/mutations'
interface Organization {
@@ -21,6 +21,9 @@ interface Organization {
createdAt: string
users?: Array<{ id: string, avatar?: string }>
isCounterparty?: boolean
+ isCurrentUser?: boolean
+ hasOutgoingRequest?: boolean
+ hasIncomingRequest?: boolean
}
export function MarketWholesale() {
@@ -31,9 +34,15 @@ export function MarketWholesale() {
})
const [sendRequest, { loading: sendingRequest }] = useMutation(SEND_COUNTERPARTY_REQUEST, {
- onCompleted: () => {
- refetch()
- }
+ refetchQueries: [
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'SELLER' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'FULFILLMENT' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'LOGIST' } },
+ { query: SEARCH_ORGANIZATIONS, variables: { type: 'WHOLESALE' } },
+ { query: GET_OUTGOING_REQUESTS },
+ { query: GET_INCOMING_REQUESTS }
+ ],
+ awaitRefetchQueries: true
})
const handleSearch = () => {
@@ -44,7 +53,7 @@ export function MarketWholesale() {
try {
await sendRequest({
variables: {
- receiverId: organizationId,
+ organizationId: organizationId,
message: message || 'Заявка на добавление в контрагенты'
}
})
diff --git a/src/components/market/organization-card.tsx b/src/components/market/organization-card.tsx
index 9e1b009..72468ac 100644
--- a/src/components/market/organization-card.tsx
+++ b/src/components/market/organization-card.tsx
@@ -11,7 +11,8 @@ import {
Calendar,
Plus,
Send,
- Trash2
+ Trash2,
+ User
} from 'lucide-react'
import { OrganizationAvatar } from './organization-avatar'
import { useState } from 'react'
@@ -28,6 +29,9 @@ interface Organization {
createdAt: string
users?: Array<{ id: string, avatar?: string }>
isCounterparty?: boolean
+ isCurrentUser?: boolean
+ hasOutgoingRequest?: boolean
+ hasIncomingRequest?: boolean
}
interface OrganizationCardProps {
@@ -144,7 +148,12 @@ export function OrganizationCard({
{getTypeLabel(organization.type)}
- {organization.isCounterparty && (
+ {organization.isCurrentUser && (
+
+ Это вы
+
+ )}
+ {organization.isCounterparty && !organization.isCurrentUser && (
Уже добавлен
@@ -190,16 +199,29 @@ export function OrganizationCard({
Удалить из контрагентов
+ ) : organization.isCurrentUser ? (
+
) : (