Written good code and made bug fixes
This commit is contained in:
parent
db08e1001e
commit
b51b71ffa6
|
@ -0,0 +1,39 @@
|
|||
import { Component } from "react"
|
||||
|
||||
class ErrorBoundary extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
// Define a state variable to track whether is an error or not
|
||||
this.state = { hasError: false }
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
// Update state so the next render will show the fallback UI
|
||||
return { hasError: true }
|
||||
}
|
||||
componentDidCatch(error, errorInfo) {
|
||||
// You can use your own error logging service here
|
||||
console.log({ error, errorInfo })
|
||||
}
|
||||
render() {
|
||||
// Check if the error is thrown
|
||||
if (this.state.hasError) {
|
||||
// You can render any custom fallback UI
|
||||
return (
|
||||
<div>
|
||||
<h2>Oops, there is an error!</h2>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => this.setState({ hasError: false })}
|
||||
>
|
||||
Try again?
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
// Return children components in case of no error
|
||||
return this.props.children
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorBoundary
|
||||
|
|
@ -3,115 +3,44 @@ import SkillCard from "../skillCard";
|
|||
|
||||
export default function ({ title, image, evt1, evt2, evt3, url }) {
|
||||
let ghLogo = "/images/github_events/GitIcon.png";
|
||||
console.log(title,image,evt1,evt2,evt3,url)
|
||||
// Evt1
|
||||
if (evt1?.type === "PushEvent") {
|
||||
evt1.entTypeLogo = "/images/github_events/github_push_event_logo.png";
|
||||
evt1.commitMsg = evt1.payload.commits[0].message;
|
||||
} else if (evt1?.type === "WatchEvent") {
|
||||
evt1.entTypeLogo = "/images/github_events/github_watch_event_logo.png";
|
||||
} else if (evt1?.type === "IssuesEvent") {
|
||||
evt1.entTypeLogo = "/images/github_events/github_issues_event_logo.png";
|
||||
if (evt1?.payload.action === "opened") {
|
||||
evt1.commitMsg = "Opened " + evt1.payload.issue.title;
|
||||
} else if (evt1?.payload.action === "closed") {
|
||||
evt1.commitMsg = "Closed " + evt1.payload.issue.title;
|
||||
|
||||
[evt1, evt2, evt3].map((evt) => {
|
||||
if (evt?.type === "PushEvent") {
|
||||
evt.entTypeLogo = "/images/github_events/github_push_event_logo.png";
|
||||
evt.commitMsg = evt.payload.commits[0].message;
|
||||
} else if (evt?.type === "WatchEvent") {
|
||||
evt.entTypeLogo = "/images/github_events/github_watch_event_logo.png";
|
||||
} else if (evt?.type === "IssuesEvent") {
|
||||
evt.entTypeLogo = "/images/github_events/github_issues_event_logo.png";
|
||||
if (evt?.payload.action === "opened") {
|
||||
evt.commitMsg = "Opened " + evt.payload.issue.title;
|
||||
} else if (evt?.payload.action === "closed") {
|
||||
evt.commitMsg = "Closed " + evt.payload.issue.title;
|
||||
}
|
||||
} else if (evt?.type === "DeleteEvent") {
|
||||
evt.entTypeLogo = "/images/github_events/github_delete_event_logo.png";
|
||||
evt.commitMsg =
|
||||
evt.payload.ref_type + " " + evt.payload.ref + " deleted";
|
||||
} else if (evt?.type === "IssueCommentEvent") {
|
||||
evt.entTypeLogo =
|
||||
"/images/github_events/github_issue_comment_event_logo.png";
|
||||
evt.commitMsg = evt.payload.comment.body;
|
||||
} else if (evt?.type === "CreateEvent") {
|
||||
evt.entTypeLogo = "/images/github_events/github_create_event_logo.png";
|
||||
evt.commitMsg = evt.payload.ref_type;
|
||||
} else if (evt?.type === "PullRequestEvent") {
|
||||
evt.entTypeLogo =
|
||||
"/images/github_events/github_pull_request_event_logo.png";
|
||||
if (evt?.payload.action === "opened") {
|
||||
evt.commitMsg = "Opened " + evt.payload.pull_request.title;
|
||||
} else if (evt?.payload.action === "closed") {
|
||||
evt.commitMsg = "Closed " + evt.payload.pull_request.title;
|
||||
}
|
||||
} else if (evt?.type === "ForkEvent") {
|
||||
evt.entTypeLogo = "/images/github_events/github_fork_event_logo.png";
|
||||
evt.commitMsg = "Forked " + evt.payload.forkee.full_name;
|
||||
}
|
||||
} else if (evt1?.type === "DeleteEvent") {
|
||||
evt1.entTypeLogo = "/images/github_events/github_delete_event_logo.png";
|
||||
evt1.commitMsg =
|
||||
evt1.payload.ref_type + " " + evt1.payload.ref + " deleted";
|
||||
} else if (evt1?.type === "IssueCommentEvent") {
|
||||
evt1.entTypeLogo =
|
||||
"/images/github_events/github_issue_comment_event_logo.png";
|
||||
evt1.commitMsg = evt1.payload.comment.body;
|
||||
} else if (evt1?.type === "CreateEvent") {
|
||||
evt1.entTypeLogo = "/images/github_events/github_create_event_logo.png";
|
||||
evt1.commitMsg = evt1.payload.ref_type;
|
||||
} else if (evt1?.type === "PullRequestEvent") {
|
||||
evt1.entTypeLogo =
|
||||
"/images/github_events/github_pull_request_event_logo.png";
|
||||
if (evt1?.payload.action === "opened") {
|
||||
evt1.commitMsg = "Opened " + evt1.payload.pull_request.title;
|
||||
} else if (evt1?.payload.action === "closed") {
|
||||
evt1.commitMsg = "Closed " + evt1.payload.pull_request.title;
|
||||
}
|
||||
} else if (evt1?.type === "ForkEvent") {
|
||||
evt1.entTypeLogo = "/images/github_events/github_fork_event_logo.png";
|
||||
evt1.commitMsg = "Forked " + evt1.payload.forkee.full_name;
|
||||
}
|
||||
// Evt2
|
||||
if (evt2?.type === "PushEvent") {
|
||||
evt2.entTypeLogo = "/images/github_events/github_push_event_logo.png";
|
||||
evt2.commitMsg = evt2.payload.commits[0].message;
|
||||
} else if (evt2?.type === "WatchEvent") {
|
||||
evt2.entTypeLogo = "/images/github_events/github_watch_event_logo.png";
|
||||
} else if (evt2?.type === "IssuesEvent") {
|
||||
evt2.entTypeLogo = "/images/github_events/github_issues_event_logo.png";
|
||||
if (evt2?.payload.action === "opened") {
|
||||
evt2.commitMsg = "Opened " + evt2.payload.issue.title;
|
||||
} else if (evt2?.payload.action === "closed") {
|
||||
evt2.commitMsg = "Closed " + evt2.payload.issue.title;
|
||||
}
|
||||
} else if (evt2?.type === "DeleteEvent") {
|
||||
evt2.entTypeLogo = "/images/github_events/github_delete_event_logo.png";
|
||||
evt2.commitMsg =
|
||||
evt2.payload.ref_type + " " + evt2.payload.ref + " deleted";
|
||||
} else if (evt2?.type === "IssueCommentEvent") {
|
||||
evt2.entTypeLogo =
|
||||
"/images/github_events/github_issue_comment_event_logo.png";
|
||||
evt2.commitMsg = evt2.payload.comment.body;
|
||||
} else if (evt2?.type === "CreateEvent") {
|
||||
evt2.entTypeLogo = "/images/github_events/github_create_event_logo.png";
|
||||
evt2.commitMsg = evt2.payload.ref_type;
|
||||
} else if (evt2?.type === "PullRequestEvent") {
|
||||
evt2.entTypeLogo =
|
||||
"/images/github_events/github_pull_request_event_logo.png";
|
||||
if (evt2?.payload.action === "opened") {
|
||||
evt2.commitMsg = "Opened " + evt2.payload.pull_request.title;
|
||||
} else if (evt2?.payload.action === "closed") {
|
||||
evt2.commitMsg = "Closed " + evt2.payload.pull_request.title;
|
||||
}
|
||||
} else if (evt2?.type === "ForkEvent") {
|
||||
evt2.entTypeLogo = "/images/github_events/github_fork_event_logo.png";
|
||||
evt2.commitMsg = "Forked " + evt2.payload.forkee.full_name;
|
||||
}
|
||||
// Evt3
|
||||
if (evt3?.type === "PushEvent") {
|
||||
evt3.entTypeLogo = "/images/github_events/github_push_event_logo.png";
|
||||
evt3.commitMsg = evt3.payload.commits[0].message;
|
||||
} else if (evt3?.type === "WatchEvent") {
|
||||
evt3.entTypeLogo = "/images/github_events/github_watch_event_logo.png";
|
||||
} else if (evt3?.type === "IssuesEvent") {
|
||||
evt3.entTypeLogo = "/images/github_events/github_issues_event_logo.png";
|
||||
if (evt3?.payload.action === "opened") {
|
||||
evt3.commitMsg = "Opened " + evt3.payload.issue.title;
|
||||
} else if (evt3?.payload.action === "closed") {
|
||||
evt3.commitMsg = "Closed " + evt3.payload.issue.title;
|
||||
}
|
||||
} else if (evt3?.type === "DeleteEvent") {
|
||||
evt3.entTypeLogo = "/images/github_events/github_delete_event_logo.png";
|
||||
evt3.commitMsg =
|
||||
evt3.payload.ref_type + " " + evt3.payload.ref + " deleted";
|
||||
} else if (evt3?.type === "IssueCommentEvent") {
|
||||
evt3.entTypeLogo =
|
||||
"/images/github_events/github_issue_comment_event_logo.png";
|
||||
evt3.commitMsg = evt3.payload.comment.body;
|
||||
} else if (evt3?.type === "CreateEvent") {
|
||||
evt3.entTypeLogo = "/images/github_events/github_create_event_logo.png";
|
||||
evt3.commitMsg = evt3.payload.ref_type;
|
||||
} else if (evt3?.type === "PullRequestEvent") {
|
||||
evt3.entTypeLogo =
|
||||
"/images/github_events/github_pull_request_event_logo.png";
|
||||
if (evt3?.payload.action === "opened") {
|
||||
evt3.commitMsg = "Opened " + evt3.payload.pull_request.title;
|
||||
} else if (evt3?.payload.action === "closed") {
|
||||
evt3.commitMsg = "Closed " + evt3.payload.pull_request.title;
|
||||
}
|
||||
} else if (evt3?.type === "ForkEvent") {
|
||||
evt3.entTypeLogo = "/images/github_events/github_fork_event_logo.png";
|
||||
evt3.commitMsg = "Forked " + evt3.payload.forkee.full_name;
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<SkillCard title={title} image={image} url={url}>
|
||||
|
|
|
@ -10,7 +10,7 @@ export default function () {
|
|||
const [skills, setSkills] = useState({});
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
async function requestAPIS() {
|
||||
async function requestAPIS() {
|
||||
await APISDK.req();
|
||||
APISDK.data.logo = {
|
||||
masto: `https://cdn.fosstodon.org/accounts/avatars/000/028/400/original/324cba4cb379bd4e.png`,
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
import "../styles/globals.css";
|
||||
// import CustomCursor from "components/providers/cursor";
|
||||
import ErrorBoundary from '../components/errorBoundary'
|
||||
|
||||
|
||||
|
||||
function MyPortfolio({ Component, pageProps }) {
|
||||
return (
|
||||
<>
|
||||
{/* <CustomCursor /> */}
|
||||
<Component {...pageProps} />
|
||||
<ErrorBoundary>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue