Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/zzz-frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NX_URL_GITHUB_API_ZZZ_RELEASES=https://api.github.com/repos///releases/tags/
NX_URL_GITHUB_GO_CURRENT_VERSION=
Comment on lines +1 to +2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ugh, incomplete GitHub API URL... downs another espresso

The GitHub API URL is missing the repository information in the path. This will cause the fetch to fail faster than my attempts to maintain a normal sleep schedule.

The URL should be in this format: https://api.github.com/repos/{owner}/{repo}/releases/tags/

Also, why is NX_URL_GITHUB_GO_CURRENT_VERSION empty? Are we planning to use it later? If not, we should remove it to avoid confusion.

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Verify if the API endpoint is accessible
curl -I "${NX_URL_GITHUB_API_ZZZ_RELEASES}0.1.0"

Length of output: 10694


Heads up: Incomplete GitHub API URL & empty version variable found!
It looks like the environment variable NX_URL_GITHUB_API_ZZZ_RELEASES is missing the necessary repository information ({owner}/{repo}), which ends up causing the URL to be malformed—hence the failed connection when attempting to query "0.1.0". Additionally, NX_URL_GITHUB_GO_CURRENT_VERSION remains empty, so unless it’s planned for future use, it’s probably best to remove it to avoid confusion.

  • File: apps/zzz-frontend/.env (Lines 1-2)
  • Issue 1: NX_URL_GITHUB_API_ZZZ_RELEASES should be in the format https://api.github.com/repos/{owner}/{repo}/releases/tags/
  • Issue 2: NX_URL_GITHUB_GO_CURRENT_VERSION is empty and might be unnecessary.

2 changes: 1 addition & 1 deletion apps/zzz-frontend/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ScrollTop } from '@genshin-optimizer/common/ui'
import { DatabaseProvider } from '@genshin-optimizer/zzz/db-ui'
import '@genshin-optimizer/zzz/i18n' // import to load translations
import PageHome from '@genshin-optimizer/zzz/page-home'
import { theme } from '@genshin-optimizer/zzz/theme'
import {
Box,
Expand All @@ -14,7 +15,6 @@ import { Suspense, lazy } from 'react'
import { HashRouter, Route, Routes } from 'react-router-dom'
import '../styles.scss'
import Header from './Header'
import PageHome from './PageHome'
const PageDiscs = lazy(() => import('@genshin-optimizer/zzz/page-discs'))
const PageOptimize = lazy(() => import('@genshin-optimizer/zzz/page-optimize'))
const PageCharacters = lazy(
Expand Down
33 changes: 0 additions & 33 deletions apps/zzz-frontend/src/app/PageHome.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions apps/zzz-frontend/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { defineConfig, normalizePath } from 'vite'
// https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import pkg from '../../package.json' assert { type: 'json' }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you wanna use zzz-frontend package json version instead?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree, except we have no package.json there, and we have not been tracking version for ZO.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also add it in project.json if its allowed, or create package.json if allowed. either way, we have options available for separate version per-site


export default defineConfig({
base: '',
Expand Down Expand Up @@ -64,6 +65,7 @@ export default defineConfig({

define: {
'process.env': process.env,
__VERSION__: `"${pkg.version}"`,
},

// Uncomment this if you are using workers.
Expand Down
11 changes: 11 additions & 0 deletions libs/zzz/localization/assets/locales/en/page_home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"quickLinksCard": {
"title": "Quick Links",
"buttons": {
"patchNotes": {
"title": "Patch Notes",
"tooltip": "All of ZO's patch notes"
}
}
}
}
13 changes: 13 additions & 0 deletions libs/zzz/page-home/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage",
"importSource": "@emotion/react"
}
]
],
"plugins": ["@emotion/babel-plugin"]
}
21 changes: 21 additions & 0 deletions libs/zzz/page-home/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"parserOptions": {
"project": "libs/zzz/page-home/tsconfig.eslint.json"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/zzz/page-home/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# zzz-page-home

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test zzz-page-home` to execute the unit tests via [Jest](https://jestjs.io).
8 changes: 8 additions & 0 deletions libs/zzz/page-home/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "zzz-page-home",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/zzz/page-home/src",
"projectType": "library",
"tags": [],
"targets": {}
}
81 changes: 81 additions & 0 deletions libs/zzz/page-home/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { CardThemed } from '@genshin-optimizer/common/ui'
import DescriptionIcon from '@mui/icons-material/Description'
import { CardContent, CardHeader, Divider, Typography } from '@mui/material'
import { Box } from '@mui/system'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'

declare const __VERSION__: string
export default function PageHome() {
return (
<CardThemed sx={{ my: 1 }}>
<CardContent>
<Typography variant="h5">I know what this looks like...</Typography>
<Typography>
This is an <i>Alpha</i>(desperately unfinished) version of{' '}
<strong>Zenless Optimizer</strong>. You have to understand, this is
the result of asking,
</Typography>
<Typography variant="caption">
"What is the most Optimizer I can, if I was cutting corners like it's
crunch time at a circle factory?" — frzyc, probably
</Typography>
<Typography>
I know a lot of stuff isn't implemented, and the stuff that are, are
super ugly. This is only like{' '}
<Box component="span" sx={{ textDecoration: 'line-through' }}>
10
</Box>{' '}
20 hours of coding, cut me some slack.
</Typography>
<Typography sx={{ my: 1 }}>Have an optimal day,</Typography>
<Typography>
<strong>frzyc</strong>
</Typography>
</CardContent>
<Divider />
<PatchNotesCard />
</CardThemed>
)
}

function PatchNotesCard() {
const { t } = useTranslation('page_home')
const [{ isLoaded, text }, setState] = useState({ isLoaded: false, text: '' })
useEffect(() => {
const regex = /^(\d+)\.(\d+)\.(\d+)$/
const minorVersion = __VERSION__.replace(regex, `$1.$2.${0}`)
fetch(process.env['NX_URL_GITHUB_API_ZZZ_RELEASES'] + minorVersion)
.then((res) => res.arrayBuffer())
.then((buffer) => {
const decoder = new TextDecoder('utf-8')
const data = decoder.decode(buffer)
const release = JSON.parse(data)
setState({ isLoaded: true, text: release.body })
})
.catch((err) => console.log('Error: ' + err.message))
}, [])
Comment on lines +44 to +59

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Error handling needs some love... rubs eyes

The fetch error handling just logs to console. We should show a user-friendly error message. Trust me, I've spent too many nights debugging silent failures.

-      .catch((err) => console.log('Error: ' + err.message))
+      .catch((err) => {
+        console.error('Failed to fetch patch notes:', err);
+        setState({ isLoaded: true, text: 'Failed to load patch notes. Please try again later.' });
+      })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function PatchNotesCard() {
const { t } = useTranslation('page_home')
const [{ isLoaded, text }, setState] = useState({ isLoaded: false, text: '' })
useEffect(() => {
const regex = /^(\d+)\.(\d+)\.(\d+)$/
const minorVersion = __VERSION__.replace(regex, `$1.$2.${0}`)
fetch(process.env['NX_URL_GITHUB_API_ZZZ_RELEASES'] + minorVersion)
.then((res) => res.arrayBuffer())
.then((buffer) => {
const decoder = new TextDecoder('utf-8')
const data = decoder.decode(buffer)
const release = JSON.parse(data)
setState({ isLoaded: true, text: release.body })
})
.catch((err) => console.log('Error: ' + err.message))
}, [])
function PatchNotesCard() {
const { t } = useTranslation('page_home')
const [{ isLoaded, text }, setState] = useState({ isLoaded: false, text: '' })
useEffect(() => {
const regex = /^(\d+)\.(\d+)\.(\d+)$/
const minorVersion = __VERSION__.replace(regex, `$1.$2.${0}`)
fetch(process.env['NX_URL_GITHUB_API_ZZZ_RELEASES'] + minorVersion)
.then((res) => res.arrayBuffer())
.then((buffer) => {
const decoder = new TextDecoder('utf-8')
const data = decoder.decode(buffer)
const release = JSON.parse(data)
setState({ isLoaded: true, text: release.body })
})
.catch((err) => {
console.error('Failed to fetch patch notes:', err);
setState({ isLoaded: true, text: 'Failed to load patch notes. Please try again later.' });
})
}, [])
}


return (
<CardThemed>
<CardHeader
title={
<Typography variant="h5">
{t('quickLinksCard.buttons.patchNotes.title')}
</Typography>
}
avatar={<DescriptionIcon fontSize="large" />}
sx={{ padding: '16px 16px 0 16px' }}
/>
<CardContent>
{isLoaded ? (
<ReactMarkdown children={text} remarkPlugins={[remarkGfm]} />
) : (
'Loading...'
)}
</CardContent>
</CardThemed>
)
}
8 changes: 8 additions & 0 deletions libs/zzz/page-home/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"types": ["node"]
},
"include": ["**/*.ts", "**/*.tsx"]
}
19 changes: 19 additions & 0 deletions libs/zzz/page-home/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"jsxImportSource": "@emotion/react",
"exactOptionalPropertyTypes": false
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
],
"extends": "../../../tsconfig.base.json"
}
24 changes: 24 additions & 0 deletions libs/zzz/page-home/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"types": [
"node",
"object-overrides",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"exclude": [
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@
"@genshin-optimizer/zzz/theme": ["libs/zzz/theme/src/index.ts"],
"@genshin-optimizer/zzz/ui": ["libs/zzz/ui/src/index.tsx"],
"@genshin-optimizer/zzz/util": ["libs/zzz/util/src/index.ts"],
"@genshin-optimizer/zzz/zood": ["libs/zzz/zood/src/index.ts"]
"@genshin-optimizer/zzz/zood": ["libs/zzz/zood/src/index.ts"],
"@genshin-optimizer/zzz/page-home": ["libs/zzz/page-home/src/index.tsx"]
}
},
"exclude": ["node_modules", "tmp"]
Expand Down