Skip to content

Commit

Permalink
perf(frontend): Move lang & advanced pages admin to package
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Jun 28, 2024
1 parent 0ab072c commit e60da7e
Show file tree
Hide file tree
Showing 52 changed files with 761 additions and 359 deletions.
Original file line number Diff line number Diff line change
@@ -1,64 +1,8 @@
import { getTranslations } from 'next-intl/server';
import { Metadata } from 'next';
import { Card } from 'vitnode-frontend/components/ui/card';
import { fetcher } from 'vitnode-frontend/graphql/fetcher';
import { HeaderContent } from 'vitnode-frontend/components/ui/header-content';

import {
Admin__Core_Files__Show,
ShowCoreFilesSortingColumnEnum,
Admin__Core_Files__ShowQuery,
Admin__Core_Files__ShowQueryVariables,
} from '@/graphql/hooks';
import {
usePaginationAPISsr,
SearchParamsPagination,
} from '@/plugins/core/hooks/utils/use-pagination-api-ssr';
import { FilesAdvancedCoreAdminView } from '@/plugins/admin/views/core/advanced/files/files-advanced-core-admin-view';

const getData = async (variables: Admin__Core_Files__ShowQueryVariables) => {
const { data } = await fetcher<
Admin__Core_Files__ShowQuery,
Admin__Core_Files__ShowQueryVariables
>({
query: Admin__Core_Files__Show,
variables,
});

return data;
};

interface Props {
searchParams: SearchParamsPagination;
}

export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations('admin.core.advanced.files');

return {
title: t('title'),
};
}

export default async function Page({ searchParams }: Props) {
const variables = usePaginationAPISsr({
searchParams,
defaultPageSize: 10,
search: true,
sortByEnum: ShowCoreFilesSortingColumnEnum,
});
const [t, data] = await Promise.all([
getTranslations('admin.core.advanced.files'),
getData(variables),
]);

return (
<>
<HeaderContent h1={t('title')} />
FilesAdvancedCoreAdminView,
FilesAdvancedCoreAdminViewProps,
} from 'vitnode-frontend/admin/core/advanced/files/files-advanced-core-admin-view';

<Card className="p-6">
<FilesAdvancedCoreAdminView {...data} />
</Card>
</>
);
export default function Page(props: FilesAdvancedCoreAdminViewProps) {
return <FilesAdvancedCoreAdminView {...props} />;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,72 +1,8 @@
import { Metadata } from 'next';
import { getTranslations } from 'next-intl/server';
import { Card } from 'vitnode-frontend/components/ui/card';
import { fetcher } from 'vitnode-frontend/graphql/fetcher';
import { HeaderContent } from 'vitnode-frontend/components/ui/header-content';

import {
Core_Languages__Show,
ShowCoreLanguagesSortingColumnEnum,
Core_Languages__ShowQuery,
Core_Languages__ShowQueryVariables,
} from '@/graphql/hooks';
import {
usePaginationAPISsr,
SearchParamsPagination,
} from '@/plugins/core/hooks/utils/use-pagination-api-ssr';
import { ActionsLangsAdmin } from '@/plugins/admin/views/core/langs/actions/actions';
import { RebuildRequiredAdmin } from '@/plugins/admin/global/rebuild-required';
import { LangsCoreAdminView } from '@/plugins/admin/views/core/langs/langs-core-admin-view';

const getData = async (variables: Core_Languages__ShowQueryVariables) => {
const { data } = await fetcher<
Core_Languages__ShowQuery,
Core_Languages__ShowQueryVariables
>({
query: Core_Languages__Show,
variables,
});

return data;
};
interface Props {
params: {
locale: string;
};
searchParams: SearchParamsPagination;
}

export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations('admin.core.langs');

return {
title: t('title'),
};
}

export default async function Page({ searchParams }: Props) {
const variables = usePaginationAPISsr({
searchParams,
defaultPageSize: 10,
search: true,
sortByEnum: ShowCoreLanguagesSortingColumnEnum,
});

const [t, data] = await Promise.all([
getTranslations('admin.core.langs'),
getData(variables),
]);

return (
<>
<HeaderContent h1={t('title')}>
<ActionsLangsAdmin />
</HeaderContent>
LangsCoreAdminView,
LangsCoreAdminViewProps,
} from 'vitnode-frontend/admin/core/langs/langs-core-admin-view';

<Card className="p-6">
<RebuildRequiredAdmin />
<LangsCoreAdminView data={data} />
</Card>
</>
);
export default function Page(props: LangsCoreAdminViewProps) {
return <LangsCoreAdminView {...props} />;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
query Core_languages__show(
query Admin_Core_languages__show(
$first: Int
$last: Int
$cursor: Int
Expand Down
16 changes: 7 additions & 9 deletions packages/frontend/src/components/ui/user/user-input.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as React from 'react';
import { useTranslations } from 'next-intl';
import { X } from 'lucide-react';
import { cn } from 'vitnode-frontend/helpers/classnames';
import { Button } from 'vitnode-frontend/components/ui/button';
import { Loader } from 'vitnode-frontend/components/ui/loader';
import {
Popover,
PopoverContent,
PopoverTrigger,
} from 'vitnode-frontend/components/ui/popover';
import { Badge } from 'vitnode-frontend/components/ui/badge';

import { Popover, PopoverContent, PopoverTrigger } from '../popover';
import { Button } from '../button';
import { Loader } from '../loader';
import { Badge } from '../badge';

import { cn } from '../../../helpers/classnames';

const UserInputContent = React.lazy(async () =>
import('../../../utils/components/user/user-input/content').then(module => ({
Expand Down
Loading

0 comments on commit e60da7e

Please sign in to comment.