-
Notifications
You must be signed in to change notification settings - Fork 3
fix(inbox) ui #349
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?
fix(inbox) ui #349
Changes from 1 commit
37d6ca4
ed63882
8b6b8ae
43063ae
39ef6ef
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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,9 @@ | ||||||
| import { IIntegrationDocument } from '@/inbox/@types/integrations'; | ||||||
| import { IContext } from '~/connectionResolvers'; | ||||||
| import { facebookStatus } from '@/integrations/facebook/messageBroker'; | ||||||
| import { graphRequest } from '@/integrations/facebook/utils'; | ||||||
| import { IFacebookPageResponse } from '@/integrations/facebook/@types/integrations'; | ||||||
|
|
||||||
| export const integrationStatus = async ( | ||||||
| serviceName: string, | ||||||
| subdomain: string, | ||||||
|
|
@@ -131,4 +134,60 @@ export default { | |||||
| } | ||||||
| return serviceName; | ||||||
| }, | ||||||
|
|
||||||
| async facebookPage( | ||||||
| integration: IIntegrationDocument, | ||||||
| _args, | ||||||
| { models }: IContext, | ||||||
| ) { | ||||||
| const serviceName = integration.kind.includes('facebook') | ||||||
| ? 'facebook' | ||||||
| : integration.kind; | ||||||
|
|
||||||
| if (serviceName !== 'facebook') { | ||||||
| return null; | ||||||
| } | ||||||
|
|
||||||
| try { | ||||||
| const facebookIntegration = await models.FacebookIntegrations.findOne({ | ||||||
| erxesApiId: integration._id, | ||||||
| }); | ||||||
|
|
||||||
| if ( | ||||||
| !facebookIntegration || | ||||||
| !Array.isArray(facebookIntegration.facebookPageIds) | ||||||
| ) { | ||||||
| console.warn('No facebookIntegration or no facebookPageIds found'); | ||||||
| return null; | ||||||
| } | ||||||
|
|
||||||
| const results: ({ pageId: string } & IFacebookPageResponse)[] = []; | ||||||
|
|
||||||
| for (const pageId of facebookIntegration.facebookPageIds) { | ||||||
| const token = facebookIntegration.facebookPageTokensMap?.[pageId]; | ||||||
|
|
||||||
| if (!token) { | ||||||
| console.warn(`Token not found for pageId: ${pageId}`); | ||||||
| continue; | ||||||
| } | ||||||
|
|
||||||
| try { | ||||||
| const response = (await graphRequest.get( | ||||||
| `/${pageId}?fields=id,name`, | ||||||
| token, | ||||||
| )) as IFacebookPageResponse; | ||||||
|
|
||||||
| if (response) { | ||||||
| results.push({ pageId, ...response }); | ||||||
| } | ||||||
| } catch (err) { | ||||||
| console.error(`Failed to fetch page ${pageId}:`, err); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| return results.length > 0 ? results : null; | ||||||
| } catch (error) { | ||||||
| return { error }; | ||||||
|
||||||
| return { error }; | |
| throw error; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,7 @@ export const types = ` | |
| webhookData: JSON | ||
|
|
||
| brand: Brand | ||
|
|
||
| facebookPage: JSON | ||
| channels: [Channel] | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,6 @@ export const FacebookIntegrationEditForm = ({ | |
| }; | ||
|
|
||
| if (loading) return <Spinner className="p-20" />; | ||
|
|
||
| return ( | ||
| <> | ||
| <Dialog.Header className="flex-row items-center justify-between space-y-0 px-4 py-3"> | ||
|
|
@@ -109,6 +108,25 @@ export const FacebookIntegrationEditForm = ({ | |
| })} | ||
| > | ||
| <div className="p-6 pb-8 space-y-6"> | ||
| <Form.Field | ||
| name="facebookPage" | ||
| render={({ field }) => { | ||
| const facebookPageName = field.value?.[0] ?? null; | ||
| return ( | ||
| <Form.Item> | ||
| <Form.Label>Page Name</Form.Label> | ||
| <Form.Control> | ||
| <Input | ||
| name={field.name} | ||
| value={facebookPageName?.name || ''} | ||
| disabled | ||
| readOnly | ||
| /> | ||
| </Form.Control> | ||
| </Form.Item> | ||
| ); | ||
| }} | ||
| /> | ||
| <Form.Field | ||
| name="name" | ||
| render={({ field }) => ( | ||
|
|
@@ -134,18 +152,20 @@ export const FacebookIntegrationEditForm = ({ | |
| )} | ||
| /> | ||
| <Form.Field | ||
| name="channelIds" | ||
| render={({ field }) => ( | ||
| <Form.Item> | ||
| <Form.Label>Channels</Form.Label> | ||
| <SelectChannel.FormItem | ||
| value={field.value} | ||
| onValueChange={field.onChange} | ||
| mode="multiple" | ||
| /> | ||
| <Form.Message /> | ||
| </Form.Item> | ||
| )} | ||
| name="channels" | ||
| render={({ field }) => { | ||
| return ( | ||
| <Form.Item> | ||
| <Form.Label>Channels</Form.Label> | ||
| <SelectChannel.FormItem | ||
| value={field.value} | ||
| onValueChange={field.onChange} | ||
| mode="multiple" | ||
| /> | ||
| <Form.Message /> | ||
| </Form.Item> | ||
| ); | ||
| }} | ||
| /> | ||
|
Comment on lines
+155
to
169
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. 🧩 Analysis chainchannels field rename: verify mutation variables and schema expect channels (not channelIds). Ensure editIntegration/integrationsEdit mutations, Zod schema, and server resolvers accept channels. If backend still expects channelIds, submission will fail. 🏁 Script executed: #!/bin/bash
# Verify remaining channelIds usages and the expected mutation variables.
rg -nP -C3 '\bchannelIds\b'
rg -nP -C3 '(integrations?Edit|editIntegration)\s*\(' --type=ts --type=tsx --type=js --type=jsx
# Inspect the FB schema to confirm shape of `channels`
fd -a 'FbMessengerSchema' | xargs -I{} sh -c 'echo "==> {}"; sed -n "1,200p" "{}" | sed -n "1,200p"'Length of output: 54491 Revert to using channelIds (or update backend) — backend still expects channelIds Form field was renamed to name="channels" but frontend Zod schemas, GraphQL mutations, and backend resolvers/schemas still use channelIds; this will break submissions. Revert the Form.Field to name="channelIds" or update/map all layers to accept "channels" -> "channelIds". Files to fix or align:
🤖 Prompt for AI Agents |
||
| </div> | ||
| <Separator /> | ||
|
|
||
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.
Consider parallelizing the independent Facebook page requests (e.g. with Promise.all) for potential performance improvements.