-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46df3a3
commit 7f6b651
Showing
14 changed files
with
514 additions
and
164 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
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,54 @@ | ||
import { ActionFunctionArgs, json } from '@remix-run/node' | ||
import { Link, Outlet, useActionData } from '@remix-run/react' | ||
import { | ||
mailchimpApiKeyKey, | ||
mailchimpServerPrefixKey, | ||
onesignalAppIdKey, | ||
prefsCookie, | ||
} from '~/common/cookies' | ||
import { buildMailchimpDao } from '~/common/mailchimp-dao' | ||
|
||
export default function Mailchimp() { | ||
const actionData = useActionData<typeof action>() | ||
|
||
return ( | ||
<> | ||
<div className="mt-6"> | ||
<Link | ||
to={(actionData?.exportLink as any) || ''} | ||
target="_blank" | ||
className="font-l text-blue-600 dark:text-blue-500 hover:underline" | ||
> | ||
Download... | ||
</Link> | ||
<Outlet /> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export async function action({ request }: ActionFunctionArgs) { | ||
const cookieHeader = request.headers.get('Cookie') | ||
const cookie = (await prefsCookie.parse(cookieHeader)) || {} | ||
const body = await request.formData() | ||
|
||
const onesignalAppId = body.get('onesignal-app-id') as string | ||
const apiKey = body.get('mailchimp-api-key') as string | ||
const serverPrefix = body.get('mailchimp-server-prefix') as string | ||
cookie[mailchimpApiKeyKey] = apiKey | ||
cookie[onesignalAppIdKey] = onesignalAppId | ||
cookie[mailchimpServerPrefixKey] = serverPrefix | ||
|
||
const mailchimpDao = buildMailchimpDao(apiKey, serverPrefix) | ||
const exportLink = await mailchimpDao.generateExport() | ||
return json( | ||
{ | ||
exportLink, | ||
}, | ||
{ | ||
headers: { | ||
'Set-Cookie': await prefsCookie.serialize(cookie), | ||
}, | ||
} | ||
) | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.