-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement CSV Brevo Contact import in Admin Implement console command to upload CSV Brevo Contacts
- Loading branch information
1 parent
3407537
commit aae0de4
Showing
27 changed files
with
989 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
"@comet/brevo-api": major | ||
--- | ||
|
||
Add `redirectUrlForImport` to `BrevoModule` config | ||
|
||
You must now pass a `redirectUrlForImport` to your `BrevoModule` config: | ||
|
||
```ts | ||
BrevoModule.register({ | ||
brevo: { | ||
resolveConfig: (scope: EmailCampaignContentScope) => { | ||
return { | ||
// ... | ||
redirectUrlForImport: config.brevo.redirectUrlForImport, | ||
}; | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
The `redirectUrlForImport` will usually be the site URL of a scope. It is used by the CSV contact import as redirect target after the user completes the double opt-in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
"@comet/brevo-api": minor | ||
"@comet/brevo-admin": minor | ||
--- | ||
|
||
Add functionality to import Brevo contacts from CSV files | ||
|
||
You can import CSV files via the Admin interface or via CLI command. | ||
|
||
**Note:** For the import to work, you must provide a `redirectUrlForImport` to the `BrevoModule` in the API and an `apiUrl` to the `BrevoConfigProvider` in the admin. See the respective changelog entries for more information. | ||
|
||
CLI command: | ||
|
||
```bash | ||
npm run --prefix api console import-brevo-contacts -- -p <path-to-csv-file> -s '<scope-json>' [--targetGroupIds <ids...>] | ||
|
||
// Example: | ||
npm run --prefix api console import-brevo-contacts -- -p test_contacts_import.csv -s '{"domain": "main", "language":"de"}' --targetGroupIds 2618c982-fdf8-4cab-9811-a21d3272c62c,c5197539-2529-48a7-9bd1-764e9620cbd2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"@comet/brevo-admin": major | ||
--- | ||
|
||
Add `BrevoConfigProvider` | ||
|
||
You must add the new `BrevoConfigProvider` in you `App.tsx`. The config requires passing the `apiUrl`: | ||
|
||
```tsx | ||
<BrevoConfigProvider value={{ apiUrl: config.apiUrl }}>{/* ... */}</BrevoConfigProvider> | ||
``` | ||
|
||
The `apiUrl` is used by the CSV contact import to upload files to the API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
|
||
export interface BrevoConfig { | ||
apiUrl: string; | ||
} | ||
|
||
const BrevoConfigContext = React.createContext<BrevoConfig | undefined>(undefined); | ||
|
||
interface BrevoConfigProviderProps { | ||
value: BrevoConfig; | ||
} | ||
|
||
export const BrevoConfigProvider = ({ children, value }: React.PropsWithChildren<BrevoConfigProviderProps>) => { | ||
return <BrevoConfigContext.Provider value={value}>{children}</BrevoConfigContext.Provider>; | ||
}; | ||
|
||
export const useBrevoConfig = (): BrevoConfig => { | ||
const context = React.useContext(BrevoConfigContext); | ||
if (context === undefined) { | ||
throw new Error("useBrevoConfig must be used within a BrevoConfigProvider"); | ||
} | ||
return context; | ||
}; |
Oops, something went wrong.