fix: correct http return and invalid styling (#269)

* fix: correct http return and invalid styling

Page responded with incorrect http return message.

* fix: correct http return and invalid styling

Update error_page.ts
This commit is contained in:
Gabriel Logan 2024-05-22 02:07:05 -03:00 • committed by GitHub
parent f85b88a3ef
commit a50a8b71fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 5 deletions

View file

@ -80,7 +80,7 @@ async function app(req: Request): Promise<Response> {
<p>Enter your username and click get trophies</p> <p>Enter your username and click get trophies</p>
<form action="https://github-profile-trophy.vercel.app/" method="get"> <form action="https://github-profile-trophy.vercel.app/" method="get">
<label for="username">GitHub Username</label> <label for="username">GitHub Username</label>
<input type="text" name="username" id="username" placeholder="Ex. mojombo" required> <input type="text" name="username" id="username" placeholder="Ex. gabriel-logan" required>
<button type="submit">Get Trophy&apos;s</button> <button type="submit">Get Trophy&apos;s</button>
</form> </form>
</div> </div>
@ -117,7 +117,7 @@ async function app(req: Request): Promise<Response> {
const userResponseInfo = await client.requestUserInfo(username); const userResponseInfo = await client.requestUserInfo(username);
if (userResponseInfo instanceof ServiceError) { if (userResponseInfo instanceof ServiceError) {
return new Response( return new Response(
ErrorPage({ error: userInfo, username }).render(), ErrorPage({ error: userResponseInfo, username }).render(),
{ {
status: userResponseInfo.code, status: userResponseInfo.code,
headers: new Headers({ "Content-Type": "text" }), headers: new Headers({ "Content-Type": "text" }),

View file

@ -28,6 +28,14 @@ abstract class BaseError {
p { p {
color: #666; color: #666;
} }
#back-link {
display: flex;
justify-content: center;
text-decoration: none;
}
#back-link:hover {
text-decoration: underline;
}
section { section {
width: 80%; width: 80%;
margin: 0 auto; margin: 0 auto;
@ -62,7 +70,7 @@ abstract class BaseError {
cursor: pointer; cursor: pointer;
} }
#base-show { #base-show {
font-size: 14px; font-size: 16px;
color: #333; color: #333;
background-color: #f4f4f4; background-color: #f4f4f4;
padding: 10px; padding: 10px;
@ -75,12 +83,12 @@ abstract class BaseError {
} }
@media (max-width: 768px) { @media (max-width: 768px) {
#base-show { #base-show {
font-size: 14; font-size: 14px;
} }
} }
@media (max-width: 480px) { @media (max-width: 480px) {
#base-show { #base-show {
font-size: 8; font-size: 8px;
} }
} }
@media (min-width: 768px) { @media (min-width: 768px) {
@ -98,6 +106,10 @@ abstract class BaseError {
<body> <body>
<h1 style="text-align: center;">${this.status} - ${this.message}</h1> <h1 style="text-align: center;">${this.status} - ${this.message}</h1>
<p style="text-align: center;">${this.content ?? ""}</p> <p style="text-align: center;">${this.content ?? ""}</p>
${
this.content &&
'<a id="back-link" href="https://github-profile-trophy.vercel.app/">Go back</a>'
}
</body> </body>
</html>`; </html>`;