Skip to content

Commit

Permalink
Updating Remix v2 types
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomarg committed Oct 16, 2023
1 parent 9a29c15 commit 033d0d6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/routes/_index/route.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { LoaderArgs } from "@remix-run/node";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Form, useLoaderData } from "@remix-run/react";
import { login } from "../../shopify.server";
import indexStyles from "./style.css";

export const links = () => [{ rel: "stylesheet", href: indexStyles }];

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
const url = new URL(request.url);

if (url.searchParams.get("shop")) {
Expand Down
6 changes: 3 additions & 3 deletions app/routes/app._index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from "react";
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import { useActionData, useNavigation, useSubmit } from "@remix-run/react";
import {
Expand All @@ -17,13 +17,13 @@ import {
} from "@shopify/polaris";
import { authenticate } from "../shopify.server";

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
await authenticate.admin(request);

return null;
};

export const action = async ({ request }: ActionArgs) => {
export const action = async ({ request }: ActionFunctionArgs) => {
const { admin } = await authenticate.admin(request);
const color = ["Red", "Orange", "Yellow", "Green"][
Math.floor(Math.random() * 4)
Expand Down
8 changes: 4 additions & 4 deletions app/routes/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { HeadersFunction, LoaderArgs } from "@remix-run/node";
import type { HeadersFunction, LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import { Link, Outlet, useLoaderData, useRouteError } from "@remix-run/react";
import polarisStyles from "@shopify/polaris/build/esm/styles.css";
Expand All @@ -8,14 +8,14 @@ import { authenticate } from "../shopify.server";

export const links = () => [{ rel: "stylesheet", href: polarisStyles }];

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
await authenticate.admin(request);

return json({ apiKey: process.env.SHOPIFY_API_KEY });
return json({ apiKey: process.env.SHOPIFY_API_KEY || "" });
};

export default function App() {
const { apiKey } = useLoaderData();
const { apiKey } = useLoaderData<typeof loader>();

return (
<AppProvider isEmbeddedApp apiKey={apiKey}>
Expand Down
4 changes: 2 additions & 2 deletions app/routes/auth.$.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { LoaderArgs } from "@remix-run/node";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { authenticate } from "../shopify.server";

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
await authenticate.admin(request);

return null;
Expand Down
6 changes: 3 additions & 3 deletions app/routes/auth.login/route.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import {
AppProvider as PolarisAppProvider,
Expand All @@ -17,7 +17,7 @@ import { loginErrorMessage } from "./error.server";

export const links = () => [{ rel: "stylesheet", href: polarisStyles }];

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
const errors = loginErrorMessage(await login(request));

return json({
Expand All @@ -26,7 +26,7 @@ export const loader = async ({ request }: LoaderArgs) => {
});
};

export const action = async ({ request }: ActionArgs) => {
export const action = async ({ request }: ActionFunctionArgs) => {
const errors = loginErrorMessage(await login(request));

return json({
Expand Down
4 changes: 2 additions & 2 deletions app/routes/webhooks.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ActionArgs } from "@remix-run/node";
import type { ActionFunctionArgs } from "@remix-run/node";
import { authenticate } from "../shopify.server";
import db from "../db.server";

export const action = async ({ request }: ActionArgs) => {
export const action = async ({ request }: ActionFunctionArgs) => {
const { topic, shop, session, admin, payload } = await authenticate.webhook(
request
);
Expand Down

0 comments on commit 033d0d6

Please sign in to comment.