mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
refactor(page): replace accordion structure with LanguageServerAccordion component
This commit is contained in:
parent
bd085751b6
commit
6c53c5ee32
@ -1,58 +1,16 @@
|
|||||||
import {
|
|
||||||
Accordion,
|
|
||||||
AccordionContent,
|
|
||||||
AccordionItem,
|
|
||||||
AccordionTrigger,
|
|
||||||
} from "@/components/ui/accordion";
|
|
||||||
import { EditorLanguage } from "@prisma/client";
|
import { EditorLanguage } from "@prisma/client";
|
||||||
import { getLanguageServerConfig } from "@/app/actions/language-server";
|
import { getLanguageServerConfig } from "@/app/actions/language-server";
|
||||||
import { SettingsLanguageServerForm } from "@/app/(app)/dashboard/@admin/settings/language-server/form";
|
import { LanguageServerAccordion } from "@/app/(app)/dashboard/@admin/settings/language-server/accordion";
|
||||||
|
|
||||||
export default async function SettingsLanguageServerPage() {
|
export default async function SettingsLanguageServerPage() {
|
||||||
const languages = Object.values(EditorLanguage);
|
const languages = Object.values(EditorLanguage);
|
||||||
|
|
||||||
const configPromises = languages.map(async (language) => {
|
const configPromises = languages.map(async (language) => ({
|
||||||
return {
|
|
||||||
language,
|
language,
|
||||||
config: await getLanguageServerConfig(language),
|
config: await getLanguageServerConfig(language),
|
||||||
};
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
const configs = await Promise.all(configPromises);
|
const configs = await Promise.all(configPromises);
|
||||||
|
|
||||||
return (
|
return <LanguageServerAccordion configs={configs} />;
|
||||||
<Accordion type="single" collapsible className="w-full space-y-2" defaultValue="c">
|
|
||||||
{configs.map(({ language, config }) => (
|
|
||||||
<AccordionItem
|
|
||||||
key={language}
|
|
||||||
value={language}
|
|
||||||
className="has-focus-visible:border-ring has-focus-visible:ring-ring/50 rounded-md border outline-none last:border-b has-focus-visible:ring-[3px]"
|
|
||||||
>
|
|
||||||
<AccordionTrigger className="px-4 py-3 justify-start gap-3 text-[15px] leading-6 hover:no-underline focus-visible:ring-0 [&>svg]:-order-1">
|
|
||||||
{language.toUpperCase()}
|
|
||||||
</AccordionTrigger>
|
|
||||||
<AccordionContent className="text-muted-foreground pb-0">
|
|
||||||
<div className="px-4 py-3">
|
|
||||||
<SettingsLanguageServerForm
|
|
||||||
defaultValues={
|
|
||||||
config
|
|
||||||
? {
|
|
||||||
protocol: config.protocol,
|
|
||||||
hostname: config.hostname,
|
|
||||||
port: config.port,
|
|
||||||
path: config.path,
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
port: null,
|
|
||||||
path: null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
language={language}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</AccordionContent>
|
|
||||||
</AccordionItem>
|
|
||||||
))}
|
|
||||||
</Accordion>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user