Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat #2 : add contribution support #23

Merged
merged 26 commits into from
Apr 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9599505
fix: make image larger to avoid wrap
Juknum Apr 2, 2024
5927789
fix: remove useless `as unknown`
Juknum Apr 2, 2024
9e7068d
feat #2 : started implementation of contribute page
Juknum Apr 2, 2024
71a6049
feat #2 : add contribution deletion
Juknum Apr 3, 2024
24f98c6
feat #2 : move draft modal into its own component
Juknum Apr 3, 2024
49a9546
feat #2 : make sure contribution file is also deleted
Juknum Apr 3, 2024
cfae710
feat #2 : finish basic modal setup for draft contributions
Juknum Apr 4, 2024
c76ab8e
fix : modal offset
Juknum Apr 7, 2024
f6ed183
fix : make sure cursor is a pointer on clickable components
Juknum Apr 7, 2024
82ac1da
feat #2 : almost finished contribute page
Juknum Apr 7, 2024
2330dc1
feat #2 : add poll counts to accepted submissions
Juknum Apr 7, 2024
579f479
feat #2 : fix deleted submissions still being displayed
Juknum Apr 7, 2024
15f7ad9
feat #2 : "CSS" fixes
Juknum Apr 7, 2024
11e68d9
packages : update prisma
Juknum Apr 7, 2024
78a6a86
feat #2 : add COUNCIL role
Juknum Apr 7, 2024
f5a5c1c
feat #2 : better use for the accordion
Juknum Apr 7, 2024
d43f26c
feat #2 : add council page & contribution counselor vote
Juknum Apr 7, 2024
b276deb
fix: better name for many-to-many relations tables
Juknum Apr 7, 2024
8e49d7a
feat #2: add co-submitted accordion to submitted page
Juknum Apr 7, 2024
21a7151
fix: add new ESLint rules
Juknum Apr 7, 2024
f8ead00
fix: SCSS linting
Juknum Apr 7, 2024
eecdf39
feat #2 : add loading state when auto selecting a texture
Juknum Apr 7, 2024
64c7dd0
feat #2 : correctly update contribute page on change
Juknum Apr 7, 2024
d9efee6
feat #2: rename comp directory from submit to contribute
Juknum Apr 7, 2024
0abbb79
fix : add ESLint plugin to remove unused imports
Juknum Apr 7, 2024
7d4a0e2
tools : add more configs to .editorconfig
Juknum Apr 7, 2024
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
Prev Previous commit
Next Next commit
fix: add new ESLint rules
Juknum committed Apr 7, 2024
commit 21a71518d05e00359c59b20d61e68dc4e182b90f
2 changes: 1 addition & 1 deletion src/app/(pages)/(protected)/layout.tsx
Original file line number Diff line number Diff line change
@@ -12,6 +12,6 @@ const ProtectedLayout = ({ children }: ProtectedLayoutProps) => {
{children}
</RoleGate>
);
}
};

export default ProtectedLayout;
2 changes: 1 addition & 1 deletion src/app/(pages)/(protected)/settings/[userId]/page.tsx
Original file line number Diff line number Diff line change
@@ -18,6 +18,6 @@ const SettingsPage = () => {
</Grid.Col>
</Grid>
);
}
};

export default SettingsPage;
2 changes: 1 addition & 1 deletion src/app/(pages)/[...rest]/page.tsx
Original file line number Diff line number Diff line change
@@ -11,5 +11,5 @@ export default async function Home() {
<Title>404&nbsp;<Text component="span" fw={300} inherit>Page Not Found</Text></Title>
<Text size="lg">The page you are looking for does not exist</Text>
</Stack>
)
);
}
10 changes: 5 additions & 5 deletions src/app/(pages)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import type { Metadata } from 'next'
import type { Metadata } from 'next';

import { ColorSchemeScript, createTheme, MantineProvider } from '@mantine/core';
import { Notifications } from '@mantine/notifications';
import { SessionProvider } from 'next-auth/react'
import { SessionProvider } from 'next-auth/react';

import { auth } from '~/auth'
import { auth } from '~/auth';
import { Navbar } from '~/components/navbar';
import { BREAKPOINT_DESKTOP_LARGE } from '~/lib/constants';

// Import styles of packages that you"ve installed.
// All packages except `@mantine/hooks` require styles imports
import '@mantine/core/styles.css';
import '@mantine/dropzone/styles.css';
import '../globals.scss'
import '../globals.scss';

export const metadata: Metadata = {
title: 'Faithful Mods',
}
};

const theme = createTheme({
cursorType: 'pointer',
6 changes: 3 additions & 3 deletions src/app/(pages)/modpacks/page.tsx
Original file line number Diff line number Diff line change
@@ -4,13 +4,13 @@ import { cn } from '~/lib/utils';

const font = Poppins({
subsets: ['latin'],
weight: ['600']
})
weight: ['600'],
});

export default async function Modpacks() {
return (
<main className="flex flex-col items-center justify-center">
<h1 className={cn(font)}>Modpacks page</h1>
</main>
)
);
}
6 changes: 3 additions & 3 deletions src/app/(pages)/mods/page.tsx
Original file line number Diff line number Diff line change
@@ -4,13 +4,13 @@ import { cn } from '~/lib/utils';

const font = Poppins({
subsets: ['latin'],
weight: ['600']
})
weight: ['600'],
});

export default async function Mods() {
return (
<main className="flex flex-col items-center justify-center">
<h1 className={cn(font)}>Mods page</h1>
</main>
)
);
}
6 changes: 3 additions & 3 deletions src/app/(pages)/page.tsx
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ import { cn } from '~/lib/utils';

const font = Poppins({
subsets: ['latin'],
weight: ['600']
})
weight: ['600'],
});

export default async function Home() {
return (
<main className="flex flex-col items-center justify-center">
<h1 className={cn(font)}>Faithful Mods homepage</h1>
{ process.env.PRODUCTION ? <p>Production mode</p> : <p>Development mode</p>}
</main>
)
);
}
2 changes: 1 addition & 1 deletion src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { GET, POST } from '~/auth'
export { GET, POST } from '~/auth';
4 changes: 2 additions & 2 deletions src/auth.config.ts
Original file line number Diff line number Diff line change
@@ -10,6 +10,6 @@ export default {
Github({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
})
}),
],
} satisfies NextAuthConfig
} satisfies NextAuthConfig;
2 changes: 1 addition & 1 deletion src/components/auth/logged-user.tsx
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ export const LoggedUser = () => {

useEffectOnce(() => {
if (user) setUserPicture(user.image ?? undefined);
})
});

return (
<Tooltip
2 changes: 1 addition & 1 deletion src/components/auth/role-gate.tsx
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ export const RoleGate = ({
}
</Text>
</Stack>
)
);
}

return children;
8 changes: 4 additions & 4 deletions src/components/dashboard/dashboard-item.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Group, Image, Stack, Text } from '@mantine/core'
import { Group, Image, Stack, Text } from '@mantine/core';

import { useDeviceSize } from '~/hooks/use-device-size';
import { BREAKPOINT_DESKTOP_LARGE, BREAKPOINT_DESKTOP_MEDIUM, BREAKPOINT_MOBILE_LARGE } from '~/lib/constants';

import './dashboard.scss'
import './dashboard.scss';

export interface ItemDisplayProps {
image?: string | null,
@@ -28,7 +28,7 @@ export function DashboardItem({ image, title, description, onClick }: ItemDispla
? 2
: windowWidth <= BREAKPOINT_DESKTOP_LARGE
? 3
: 4
: 4,
}}
>
<Image
@@ -46,5 +46,5 @@ export function DashboardItem({ image, title, description, onClick }: ItemDispla
<Text size="xs" lineClamp={2}>{description?.trim() ?? 'No description'}</Text>
</Stack>
</Group>
)
);
}
Original file line number Diff line number Diff line change
@@ -28,5 +28,5 @@ export function ModpackModalGeneral({ previewImg, modpack, form }: { form: UseFo
<FileInput label="Picture" placeholder={previewImg} accept="image/*" required {...form.getInputProps('image')} />
</Stack>
</Group>
)
);
}
12 changes: 6 additions & 6 deletions src/components/dashboard/modpacks/modal/modpack-modal.tsx
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ export function ModpackModal({ modpack, onClose }: { modpack?: Modpack | undefin
},
},
onValuesChange: (value) => {
if (value.image && value.image instanceof File) setPreviewImg(value.image ? URL.createObjectURL(value.image) : modpack?.image || '')
if (value.image && value.image instanceof File) setPreviewImg(value.image ? URL.createObjectURL(value.image) : modpack?.image || '');
},
});

@@ -72,15 +72,15 @@ export function ModpackModal({ modpack, onClose }: { modpack?: Modpack | undefin
} catch (e) {
notify('Error', (e as Error).message, 'red');
}
})
}
});
};

const onDelete = (id: string) => {
startTransition(async () => {
deleteModpack(id);
onClose(id);
})
}
});
};

return (
<>
@@ -122,5 +122,5 @@ export function ModpackModal({ modpack, onClose }: { modpack?: Modpack | undefin
</Button>
</Group>
</>
)
);
}
Original file line number Diff line number Diff line change
@@ -34,30 +34,30 @@ export function ModpackVersionModal({ modpack, modpackVersion, onClose }: { modp
version: (value) => {
if (!value) return 'Version is required';
return null;
}
}
},
},
});

const saveMV = () => {
startTransition(async () => {
if (!_modpackVersion) return;

// New modpack version
if (!modpackVersion) await updateModpackVersion({ id: _modpackVersion.id, version: form.values.version })
if (!modpackVersion) await updateModpackVersion({ id: _modpackVersion.id, version: form.values.version });
// Edit of an existing modpack version
else await updateModpackVersion({ id: modpackVersion.id, version: form.values.version });

onClose();
})
}
});
};

const deleteMV = () => {
startTransition(async () => {
if (!modpackVersion) return;
await deleteModpackVersion(modpackVersion.id);
onClose();
});
}
};

const deleteModFromMV = (modVersionId: string) => {
startTransition(async () => {
@@ -67,10 +67,10 @@ export function ModpackVersionModal({ modpack, modpackVersion, onClose }: { modp
setModpackVersion(updated);
setModVersions(updated.mods);

const mods = await getModsFromIds(updated.mods.map((modVersion) => modVersion.modId))
const mods = await getModsFromIds(updated.mods.map((modVersion) => modVersion.modId));
setMods(mods);
});
}
};

const filesDrop = (files: File[]) => {
startTransition(async () => {
@@ -82,11 +82,11 @@ export function ModpackVersionModal({ modpack, modpackVersion, onClose }: { modp
const data = new FormData();
files.forEach((file) => data.append('file', file));

const updated = await addModsToModpackVersion(editedModpackVersion.id, data)
const updated = await addModsToModpackVersion(editedModpackVersion.id, data);
setModpackVersion(updated);
setModVersions(updated.mods);

const mods = await getModsFromIds(updated.mods.map((modVersion) => modVersion.modId))
const mods = await getModsFromIds(updated.mods.map((modVersion) => modVersion.modId));
setMods(mods);
} catch (e) {
notify('Error', (e as Error).message, 'red');
@@ -163,5 +163,5 @@ export function ModpackVersionModal({ modpack, modpackVersion, onClose }: { modp
</Button>
</Group>
</Stack>
)
);
}
Original file line number Diff line number Diff line change
@@ -25,17 +25,17 @@ export function ModpackVersions({ modpack }: { modpack: Modpack }) {
console.error(error);
notify('Error', error.message, 'red');
});
})
});

const openModpackVersionModal = (modpackVersion?: ModpackVersionWithMods | undefined) => {
setModalModpackVersion(modpackVersion);
openModal();
}
};

const closeModpackVersionModal = async () => {
setModpackVersions(await getModpackVersions(modpack.id));
closeModal();
}
};

return (
<>
@@ -83,5 +83,5 @@ export function ModpackVersions({ modpack }: { modpack: Modpack }) {
</Button>
</Group>
</>
)
);
}
2 changes: 1 addition & 1 deletion src/components/dashboard/modpacks/modpacks-panel.tsx
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ export function ModpacksPanel() {
console.error(err);
notify('Error', err.message, 'red');
});
}
};

const searchModpack = (search: string) => {
if (!modpacks) return;
Original file line number Diff line number Diff line change
@@ -33,8 +33,8 @@ export function ModVersionModal({ mod, modVersion, onClose }: { mod: Mod, modVer
if (!value) return 'MC Version is required';
if (value === 'unknown') return 'MC Version cannot be unknown';
return null;
}
}
},
},
});

const saveMV = () => {
@@ -43,7 +43,7 @@ export function ModVersionModal({ mod, modVersion, onClose }: { mod: Mod, modVer

await updateModVersion({ id: modVersion.id, version: form.values.version, mcVersion: form.values.mcVersion });
onClose();
})
});
};

const deleteMV = () => {
@@ -52,7 +52,7 @@ export function ModVersionModal({ mod, modVersion, onClose }: { mod: Mod, modVer

await deleteModVersion(modVersion.id);
onClose();
})
});
};

const deleteModpackFromMV = (modpackVersionId: string) => {
@@ -62,7 +62,7 @@ export function ModVersionModal({ mod, modVersion, onClose }: { mod: Mod, modVer
const updated = await removeModpackFromModVersion(modVersion.id, modpackVersionId);
setModVersionModpacks(updated);
});
}
};

return (
<Stack gap="md">
12 changes: 6 additions & 6 deletions src/components/dashboard/mods/modal/mod-versions/mod-version.tsx
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@ export function ModVersions({ mod }: { mod: Mod }) {
.catch((err) => {
console.error(err);
notify('Error', err.message, 'red');
})
})
});
});

const filesDrop = (files: File[]) => {
startTransition(() => {
@@ -39,17 +39,17 @@ export function ModVersions({ mod }: { mod: Mod }) {
);
});
});
}
};

const openModVersionModal = (modVersion?: ModVersionWithModpacks | undefined) => {
setModalModVersion(modVersion);
openModal();
}
};

const closeModVersionModal = async () => {
setModVersions(await getModVersionsWithModpacks(mod.id));
closeModal();
}
};

return (
<>
@@ -107,5 +107,5 @@ export function ModVersions({ mod }: { mod: Mod }) {
</Dropzone>
</Group>
</>
)
);
}
Loading