-
Notifications
You must be signed in to change notification settings - Fork 3
Sales fix #370
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
base: main
Are you sure you want to change the base?
Sales fix #370
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 |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ export const ItemFooter = ({ createdAt, assignedUsers = [] }: Props) => { | |
| </div> | ||
| <div className="flex"> | ||
| <MembersInline.Provider | ||
| memberIds={assignedUsers.map((user) => user._id)} | ||
|
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. nitpick: Redundant fallback for assignedUsers. If assignedUsers defaults to an empty array, you can remove the fallback to []. |
||
| memberIds={(assignedUsers || []).map((user) => user._id)} | ||
| > | ||
| <MembersInline.Avatar /> | ||
| </MembersInline.Provider> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from '@/deals/graphql/mutations/DealsMutations'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EnumCursorDirection, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ICursorListResponse, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mergeCursorData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useQueryState, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,46 +17,57 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GET_DEALS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GET_DEAL_DETAIL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from '@/deals/graphql/queries/DealsQueries'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { IDeal, IDealList } from '@/deals/types/deals'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MutationHookOptions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| QueryHookOptions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useMutation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useQuery, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from '@apollo/client'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useAtom, useAtomValue } from 'jotai'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { DEAL_LIST_CHANGED } from '~/modules/deals/graphql/subscriptions/dealListChange'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { IDeal } from '@/deals/types/deals'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { currentUserState } from 'ui-modules'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useAtomValue } from 'jotai'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { dealCreateDefaultValuesState } from '@/deals/states/dealCreateSheetState'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { dealDetailSheetState } from '@/deals/states/dealDetailSheetState'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useEffect } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface IDealChanged { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| salesDealListChanged: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| action: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deal: IDeal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const useDeals = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options?: QueryHookOptions<{ deals: IDealList }>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options?: QueryHookOptions<ICursorListResponse<IDeal>>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pipelineId?: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { data, loading, error, fetchMore, refetch, subscribeToMore } = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useQuery<{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deals: IDealList; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }>(GET_DEALS, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options?.variables, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { data, loading, fetchMore, subscribeToMore } = useQuery< | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ICursorListResponse<IDeal> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >(GET_DEALS, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { ...options?.variables }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skip: options?.skip, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetchPolicy: 'cache-and-network', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onError: (e) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: 'Error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: e.message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant: 'destructive', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentUser = useAtomValue(currentUserState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [qryStrPipelineId] = useQueryState('pipelineId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const lastPipelineId = pipelineId || qryStrPipelineId || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentUser = useAtomValue(currentUserState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { deals } = data || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { list = [], pageInfo, totalCount = 0 } = deals || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { hasPreviousPage, hasNextPage } = pageInfo || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { list: deals, pageInfo, totalCount } = data?.deals || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const unsubscribe = subscribeToMore<any>({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const unsubscribe = subscribeToMore<IDealChanged>({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document: DEAL_LIST_CHANGED, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pipelineId: lastPipelineId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -80,9 +92,9 @@ export const useDeals = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (action === 'edit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updatedList = currentList.map((item: IDeal) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return item._id === deal._id ? { ...item, ...deal } : item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updatedList = currentList.map((item: IDeal) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| item._id === deal._id ? { ...item, ...deal } : item, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (action === 'remove') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -145,81 +157,51 @@ export const useDeals = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deals: data?.deals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loading, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleFetchMore, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pageInfo, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hasPreviousPage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hasNextPage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| refetch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| totalCount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const useDealDetail = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options?: QueryHookOptions<{ dealDetail: IDeal }>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [_id] = useQueryState('salesItemId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [activeDealId] = useAtom(dealDetailSheetState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { data, loading, error } = useQuery<{ dealDetail: IDeal }>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GET_DEAL_DETAIL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options?.variables, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _id: activeDealId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skip: !_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skip: !activeDealId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { deal: data?.dealDetail, loading, error }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function useDealsEdit(options?: MutationHookOptions<any, any>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [_id] = useQueryState('salesItemId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [_id] = useAtom(dealDetailSheetState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [editDeals, { loading, error }] = useMutation(EDIT_DEALS, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options?.variables, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optimisticResponse: ({ _id, name }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dealsEdit: { __typename: 'Deal', _id, name }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| update: (cache, { data }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const updatedDeal = data?.dealsEdit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!updatedDeal) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const existing = cache.readQuery<{ deals: IDealList }>({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: GET_DEALS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!existing?.deals) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cache.writeQuery({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: GET_DEALS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deals: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...existing.deals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| list: existing.deals.list.map((d) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| d._id === updatedDeal._id ? { ...d, ...updatedDeal } : d, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| refetchQueries: _id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: GET_DEAL_DETAIL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { ...options?.variables, _id }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| refetchQueries: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: GET_DEAL_DETAIL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options?.variables, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| awaitRefetchQueries: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onCompleted: (...args) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -245,15 +227,15 @@ export function useDealsEdit(options?: MutationHookOptions<any, any>) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function useDealsAdd(options?: MutationHookOptions<any, any>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [_id] = useQueryState('salesItemId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [stageId] = useQueryState('stageId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [_id] = useAtom(dealDetailSheetState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [defaultValues] = useAtom(dealCreateDefaultValuesState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [addDeals, { loading, error }] = useMutation(ADD_DEALS, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options?.variables, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stageId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stageId: defaultValues?.stageId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| refetchQueries: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+230
to
240
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. suggestion (bug_risk): Default values for stageId may be undefined. Validate that 'defaultValues' and 'defaultValues.stageId' are defined before assigning to mutation variables, or set a fallback value to prevent sending undefined.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -288,7 +270,7 @@ export function useDealsAdd(options?: MutationHookOptions<any, any>) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function useDealsRemove(options?: MutationHookOptions<any, any>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [_id] = useQueryState('salesItemId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [_id] = useAtom(dealDetailSheetState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [removeDeals, { loading, error }] = useMutation(REMOVE_DEALS, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { AddCardForm } from '@/deals/cards/components/AddCardForm'; | ||
| import { Sheet } from 'erxes-ui'; | ||
| import { dealCreateSheetState } from '@/deals/states/dealCreateSheetState'; | ||
| import { useAtom } from 'jotai'; | ||
|
|
||
| export const AddDealSheet = () => { | ||
| const [open, setOpen] = useAtom(dealCreateSheetState); | ||
|
|
||
| const onOpen = () => { | ||
| setOpen(true); | ||
| }; | ||
|
|
||
| const onClose = () => { | ||
| setOpen(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <Sheet open={open} onOpenChange={(open) => (open ? onOpen() : onClose())}> | ||
| <Sheet.View | ||
| className="sm:max-w-3xl w-full p-0" | ||
| onEscapeKeyDown={(e) => { | ||
| e.preventDefault(); | ||
| }} | ||
| > | ||
| <AddCardForm onCloseSheet={onClose} /> | ||
| </Sheet.View> | ||
| </Sheet> | ||
| ); | ||
| }; |
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.
🧩 Analysis chain
Verify handling of undefined column values.
The type change correctly acknowledges that
columncan be undefined at runtime. However, this reveals a potential issue inBoard.tsxat line 181 whereoverItem.column as stringis used without checking for undefined. The type assertion could mask a bug where undefined is passed tosetDragOverBoardColumnId.Run the following script to verify all usages handle undefined properly:
🏁 Script executed:
Length of output: 27
🏁 Script executed:
Length of output: 13158
Use nullish coalescing instead of a type assertion for
overItem.column.Board.tsx:181: replace
with
🤖 Prompt for AI Agents