2023-01-19 11:54:57 +00:00
|
|
|
import { AppInstallationFragment } from "@dashboard/graphql";
|
|
|
|
import { useAppListContext } from "@dashboard/new-apps/context";
|
2023-01-16 09:45:12 +00:00
|
|
|
import { GetV2SaleorAppsResponse } from "@dashboard/new-apps/marketplace.types";
|
|
|
|
import { getAppDetails } from "@dashboard/new-apps/utils";
|
2023-01-10 10:04:30 +00:00
|
|
|
import { Card, CardContent } from "@material-ui/core";
|
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
|
|
|
|
import AppListCardActions from "./AppListCardActions";
|
|
|
|
import AppListCardDescription from "./AppListCardDescription";
|
|
|
|
import AppListCardIntegrations from "./AppListCardIntegrations";
|
|
|
|
import AppListCardLinks from "./AppListCardLinks";
|
|
|
|
import { useStyles } from "./styles";
|
|
|
|
|
|
|
|
interface AppListCardProps {
|
|
|
|
app: GetV2SaleorAppsResponse.SaleorApp;
|
2023-01-19 11:54:57 +00:00
|
|
|
appInstallation?: AppInstallationFragment;
|
2023-01-10 10:04:30 +00:00
|
|
|
navigateToAppInstallPage?: (manifestUrl: string) => void;
|
|
|
|
navigateToVercelDeploymentPage?: (vercelDeploymentUrl: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const AppListCard: React.FC<AppListCardProps> = ({
|
|
|
|
app,
|
2023-01-19 11:54:57 +00:00
|
|
|
appInstallation,
|
2023-01-10 10:04:30 +00:00
|
|
|
navigateToAppInstallPage,
|
|
|
|
navigateToVercelDeploymentPage,
|
|
|
|
}) => {
|
|
|
|
const classes = useStyles();
|
|
|
|
const intl = useIntl();
|
2023-01-19 11:54:57 +00:00
|
|
|
const { retryAppInstallation, removeAppInstallation } = useAppListContext();
|
2023-01-10 10:04:30 +00:00
|
|
|
|
2023-01-19 11:54:57 +00:00
|
|
|
const details = getAppDetails({
|
2023-01-10 10:04:30 +00:00
|
|
|
intl,
|
|
|
|
app,
|
2023-01-19 11:54:57 +00:00
|
|
|
appInstallation,
|
2023-01-10 10:04:30 +00:00
|
|
|
navigateToAppInstallPage,
|
|
|
|
navigateToVercelDeploymentPage,
|
2023-01-19 11:54:57 +00:00
|
|
|
retryAppInstallation,
|
|
|
|
removeAppInstallation,
|
|
|
|
});
|
2023-01-10 10:04:30 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Card className={classes.card}>
|
|
|
|
<CardContent className={classes.cardContent}>
|
|
|
|
<AppListCardDescription app={app} />
|
|
|
|
<AppListCardLinks links={details.links} />
|
|
|
|
<AppListCardIntegrations app={app} />
|
|
|
|
</CardContent>
|
|
|
|
<AppListCardActions
|
|
|
|
releaseDate={details.releaseDate}
|
2023-01-19 11:54:57 +00:00
|
|
|
installationPending={details.installationPending}
|
2023-01-10 10:04:30 +00:00
|
|
|
installHandler={details.installHandler}
|
|
|
|
vercelDeployHandler={details.vercelDeployHandler}
|
2023-01-19 11:54:57 +00:00
|
|
|
retryInstallHandler={details.retryInstallHandler}
|
|
|
|
removeInstallHandler={details.removeInstallHandler}
|
2023-01-10 10:04:30 +00:00
|
|
|
/>
|
|
|
|
</Card>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
AppListCard.displayName = "AppListCard";
|
|
|
|
export default AppListCard;
|