Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Create general loginArray function
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanDalelR committed Aug 7, 2023
1 parent 9c9bc36 commit b6acb94
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions app/linear/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import saveUserInfo from "../../utils/db/linear/saveUser";

import { authOptions } from "../api/auth/[...nextauth]/route";
import getAllPublicUserData from "../../utils/api/getAllUserPublicData";
// the recommended services should not be of the same category as the current one
import SlackLoginLink from "../../components/SlackLoginLink";
import NotionLoginLink from "../../components/NotionLoginLink";
import ConfluenceLoginLink from "../../components/ConfluenceLoginLink";
import GitHubLoginLink from "../../components/GitHubLoginLink";

import ConnectedService from "../../utils/services/page";
import LoginArray from "../../utils/services/loginArray";

export default async function ServicePage({
searchParams,
Expand Down Expand Up @@ -40,33 +37,8 @@ export default async function ServicePage({
]);

// the recommended services should not be of the same category as the current one
const services = [
{
name: "GitHub",
dataProp: "github_data",
loginComponent: <GitHubLoginLink userEmail={userEmail} />,
},
{
name: "Slack",
dataProp: "slack_data",
loginComponent: <SlackLoginLink userEmail={userEmail} />,
},
{
name: "Confluence",
dataProp: "confluence_data",
loginComponent: <ConfluenceLoginLink userEmail={userEmail} />,
},
{
name: "Notion",
dataProp: "notion_data",
loginComponent: <NotionLoginLink userEmail={userEmail} />,
},
];
const loginArray = services
.map((service) =>
userData?.[service.dataProp] ? null : service.loginComponent
)
.filter((component) => component !== null);
const nameList = ["GitHub", "Slack", "Notion", "Confluence"];
const loginArray = LoginArray({ nameList, userEmail, userData });

const json = await serviceToken.json();
if (json.error) {
Expand Down

0 comments on commit b6acb94

Please sign in to comment.