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: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/dev/types/routes.d.ts";
import "./.next/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
83 changes: 83 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"@prisma/client": "6.19",
"@swc/helpers": "^0.5.19",
"@tanstack/react-query": "^5.90.21",
"@vercel/analytics": "^2.0.1",
"@vercel/speed-insights": "^2.0.0",
"bcrypt": "^6.0.0",
"clsx": "^2.1.1",
"dotenv": "^17.3.1",
Expand Down
2 changes: 0 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ enum PlanetStatus {
enum PlanetCategory {
common
html
css
javascript
}

enum SupportedLanguage {
Expand Down
90 changes: 50 additions & 40 deletions src/app/(protected)/admin/planet/add/components/AddPlanetClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,48 +50,58 @@ const AddPlanetClient = ({ category }: Props) => {

useOrphanedImageCleanup(planetData, setPendingContentImages);

if (previewActive) {
return (
<>
<ExitPreviewButton onClick={() => setPreviewActive(false)} />
<PlanetDetails
planet={{
...planetData,
id: '',
image: {
...planetData.image,
alt: planetData.image.alt[currentLanguage.value],
},
localized: planetData.localized[currentLanguage.value],
prevPlanetId: null,
nextPlanetId: null,
}}
/>
</>
);
}
const labels = {
researchTopics: 'Research Topics',
resources: 'Resources',
contents: 'Contents',
questions: 'Questions',
previous: 'Previous',
next: 'Next',
};

return (
<PlanetEditorLayout
planetData={planetData}
setPlanetData={setPlanetData}
currentLanguage={currentLanguage}
setCurrentLanguage={setCurrentLanguage}
pendingFiles={pendingFiles}
setPendingFiles={setPendingFiles}
pendingContentImages={pendingContentImages}
setPendingContentImages={setPendingContentImages}
setPreviewActive={setPreviewActive}
title="Create New Planet"
confirmTitle="Submit Planet"
confirmBody="Are you sure you want to submit the planet?"
submitIdleLabel="Submit"
submitSubmittingLabel="Submitting..."
onSubmit={handleSubmit}
isSubmitting={isSubmitting}
isUploading={isUploading}
progress={progress}
/>
<>
{previewActive && (
<div className="absolute top-0 left-0 w-full z-500 min-h-screen">
<ExitPreviewButton onClick={() => setPreviewActive(false)} />
<PlanetDetails
planet={{
...planetData,
id: '',
image: {
...planetData.image,
alt: '',
},
localized: planetData.localized[currentLanguage.value],
prevPlanetId: null,
nextPlanetId: null,
}}
labels={labels}
/>
</div>
)}

<PlanetEditorLayout
planetData={planetData}
setPlanetData={setPlanetData}
currentLanguage={currentLanguage}
setCurrentLanguage={setCurrentLanguage}
pendingFiles={pendingFiles}
setPendingFiles={setPendingFiles}
pendingContentImages={pendingContentImages}
setPendingContentImages={setPendingContentImages}
setPreviewActive={setPreviewActive}
title="Create New Planet"
confirmTitle="Submit Planet"
confirmBody="Are you sure you want to submit the planet?"
submitIdleLabel="Submit"
submitSubmittingLabel="Submitting..."
onSubmit={handleSubmit}
isSubmitting={isSubmitting}
isUploading={isUploading}
progress={progress}
/>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,48 +50,58 @@ const UpdatePlanetClient = ({ planetId, step, initialData }: Props) => {
// Remove orphaned content images: keep only images referenced by any content in any locale
useOrphanedImageCleanup(planetData, setPendingContentImages);

if (previewActive) {
return (
<>
<ExitPreviewButton onClick={() => setPreviewActive(false)} />
<PlanetDetails
planet={{
...planetData,
id: planetId,
image: {
...planetData.image,
alt: planetData.image.alt[currentLanguage.value],
},
localized: planetData.localized[currentLanguage.value],
prevPlanetId: null,
nextPlanetId: null,
}}
/>
</>
);
}
const labels = {
researchTopics: 'Research Topics',
resources: 'Resources',
contents: 'Contents',
questions: 'Questions',
previous: 'Previous',
next: 'Next',
};

return (
<PlanetEditorLayout
planetData={planetData}
setPlanetData={setPlanetData}
currentLanguage={currentLanguage}
setCurrentLanguage={setCurrentLanguage}
pendingFiles={pendingFiles}
setPendingFiles={setPendingFiles}
pendingContentImages={pendingContentImages}
setPendingContentImages={setPendingContentImages}
setPreviewActive={setPreviewActive}
title="Edit Planet"
confirmTitle="Update Planet"
confirmBody="Are you sure you want to save changes to this planet?"
submitIdleLabel="Save changes"
submitSubmittingLabel="Saving..."
onSubmit={handleSubmit}
isSubmitting={isSubmitting}
isUploading={isUploading}
progress={progress}
/>
<>
{previewActive && (
<div className="absolute top-0 left-0 w-full z-500 min-h-screen">
<ExitPreviewButton onClick={() => setPreviewActive(false)} />
<PlanetDetails
planet={{
...planetData,
id: planetId,
image: {
...planetData.image,
alt: planetData.image.alt[currentLanguage.value],
},
localized: planetData.localized[currentLanguage.value],
prevPlanetId: null,
nextPlanetId: null,
}}
labels={labels}
/>
</div>
)}

<PlanetEditorLayout
planetData={planetData}
setPlanetData={setPlanetData}
currentLanguage={currentLanguage}
setCurrentLanguage={setCurrentLanguage}
pendingFiles={pendingFiles}
setPendingFiles={setPendingFiles}
pendingContentImages={pendingContentImages}
setPendingContentImages={setPendingContentImages}
setPreviewActive={setPreviewActive}
title="Edit Planet"
confirmTitle="Update Planet"
confirmBody="Are you sure you want to save changes to this planet?"
submitIdleLabel="Save changes"
submitSubmittingLabel="Saving..."
onSubmit={handleSubmit}
isSubmitting={isSubmitting}
isUploading={isUploading}
progress={progress}
/>
</>
);
};

Expand Down
18 changes: 15 additions & 3 deletions src/app/(public)/[locale]/roadmap/[category]/[planetId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ export const generateMetadata = async ({ params }: Props) => {
export default async function PlanetPage({ params }: Props) {
const { planetId, category, locale } = await params;
setRequestLocale(locale);
const t = await getTranslations('common');

if (!isPlanetCategory(category)) notFound();

const c = await getTranslations('common');
const t = await getTranslations('planetDetails');

const planetDetailsLabels = {
researchTopics: t('researchTopics'),
resources: t('resources'),
questions: t('questions'),
previous: t('previous'),
next: t('next'),
};


const planet = await getPlanet(
planetId,
category,
Expand All @@ -56,7 +68,7 @@ export default async function PlanetPage({ params }: Props) {
className="px-3 py-1 rounded bg-slate-800 border border-white/10 hover:bg-slate-900"
href={`/roadmap/${category}`}
>
{t('goBack')}
{c('goBack')}
</Link>

<PrivateComponent roles={['ADMIN']}>
Expand All @@ -70,7 +82,7 @@ export default async function PlanetPage({ params }: Props) {
</PrivateComponent>
</div>

<PlanetDetails planet={planet} />
<PlanetDetails planet={planet} labels={planetDetailsLabels} />
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
animation: rotate 180s linear infinite;

.link {
position: relative;
transition: scale 0.3s ease-in-out;
z-index: 2;
height: 19rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import styles from './Planet.module.scss';
interface Props {
category: string;
planet: PublicPlanetSummary;
index: number;
}

const Planet = ({ category, planet }: Props) => {
const Planet = ({ category, planet, index }: Props) => {
const { tags } = planet.localized;

return (
Expand All @@ -20,6 +21,8 @@ const Planet = ({ category, planet }: Props) => {
src={planet.image.url}
alt={planet.image.alt}
fill
priority={index < 2}
sizes="19rem"
className={styles.planet}
/>
</Link>
Expand Down
Loading
Loading