react-icons/go#GoIssueClosed JavaScript Examples

The following examples show how to use react-icons/go#GoIssueClosed. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Activities.js    From gitpedia with MIT License 4 votes vote down vote up
Activities = ({ activityData }) => {
    const extractActivity = () => {
        const message = activityData.map((activity) => {
            let icon = "";
            let action = "";
            let actionPerformed; // For Pull req
            let repoName = activity.repo.name;
            let time = new Date(activity.created_at)
                .toDateString()
                .split(" ")
                .slice(1)
                .join(" ");

            switch (activity.type) {
                case "CommitCommentEvent":
                    break;

                case "CreateEvent":
                    if (activity.payload.ref_type === "branch") {
                        icon = <GoGitBranch />;
                        action = `Created a branch ${activity.payload.ref} in `;
                    } else {
                        icon = <GoPlus />;
                        action = `Created a ${activity.payload.ref_type} in `;
                    }
                    break;

                case "DeleteEvent":
                    icon = <GoTrashcan />;
                    action = `Deleted a ${activity.payload.ref_type} ${activity.payload.ref} from `;
                    break;

                case "ForkEvent":
                    icon = <GoRepoForked />;
                    action = `Forked a repository ${repoName} to `;
                    repoName = activity.payload.forkee.full_name;
                    break;

                case "IssueCommentEvent":
                    icon = <GoComment />;
                    actionPerformed =
                        activity.payload.action.charAt(0).toUpperCase() +
                        activity.payload.action.slice(1);

                    action = `${actionPerformed} a comment on an issue in `;
                    break;

                case "IssuesEvent":
                    if (activity.payload.action === "closed") {
                        icon = <GoIssueClosed />;
                    } else {
                        icon = <GoIssueOpened />;
                    }
                    actionPerformed =
                        activity.payload.action.charAt(0).toUpperCase() +
                        activity.payload.action.slice(1);

                    action = `${actionPerformed} an issue in `;
                    break;

                case "PullRequestEvent":
                    if (activity.payload.action === "closed") {
                        icon = <GoTrashcan />;
                    } else {
                        icon = <GoRepoPull />;
                    }

                    actionPerformed =
                        activity.payload.action.charAt(0).toUpperCase() +
                        activity.payload.action.slice(1);

                    action = `${actionPerformed} a pull request in `;
                    break;

                case "PullRequestReviewCommentEvent":
                    icon = <GoComment />;
                    actionPerformed =
                        activity.payload.action.charAt(0).toUpperCase() +
                        activity.payload.action.slice(1);

                    action = `${actionPerformed} a comment on their pull request in `;
                    break;

                case "PushEvent":
                    icon = <GoRepoPush />;
                    let commit = "commit";
                    let branch = activity.payload.ref.slice(11);

                    if (activity.payload.size > 1) {
                        commit = "commits";
                    }

                    action = `Pushed ${activity.payload.size} ${commit} to ${branch} in `;
                    break;

                case "WatchEvent":
                    icon = <GoStar />;
                    action = "Starred the repository ";
                    break;

                case "ReleaseEvent":
                    icon = <GoBook />;
                    actionPerformed =
                        activity.payload.action.charAt(0).toUpperCase() +
                        activity.payload.action.slice(1);

                    action = `${actionPerformed} a release in `;
                    break;

                default:
                    action = "";
            }
            return { icon, action, repoName, time };
        });

        return message;
    };

    const buildActivityList = () => {
        const messages = extractActivity();

        if (messages.length !== 0) {
            return messages.map((message) => (
                <li>
                    <ActivitiesItem>
                        <ActivityDiv>
                            <span>
                                {message.icon} {message.action}
                            </span>
                            <a href={`https://github.com/${message.repoName}`}>
                                {message.repoName}
                            </a>
                        </ActivityDiv>
                        <TimeDiv>{message.time}</TimeDiv>
                    </ActivitiesItem>
                </li>
            ));
        } else {
            return (
                <li>
                    <ActivitiesItem>
                        <FlexContainer>
                            No recent activities found :(
                        </FlexContainer>
                    </ActivitiesItem>
                </li>
            );
        }

    };

    return (
        <>
            <ActivitiesContainer>
                <ul>{buildActivityList()}</ul>
            </ActivitiesContainer>
        </>
    );
}