-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change versions of next-admin * Upgrade next-admin to 3.2.1 with parse patch * Fix delete and set image as text field * Upgrade next-admin 3.2.5
- Loading branch information
Showing
7 changed files
with
228 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
'use server'; | ||
import client from '@/lib/db'; | ||
import { options } from '@/utils/nextadmin'; | ||
import { ActionParams } from '@premieroctet/next-admin'; | ||
import { submitForm } from '@premieroctet/next-admin/dist/actions'; | ||
import { ActionParams, ModelName } from '@premieroctet/next-admin'; | ||
import { deleteResourceItems, submitForm } from '@premieroctet/next-admin/dist/actions'; | ||
|
||
export const submitFormAction = async ( | ||
params: ActionParams, | ||
formData: FormData | ||
) => { | ||
return submitForm({ ...params, options, prisma: client }, formData); | ||
}; | ||
|
||
export const deleteItem = async ( | ||
model: ModelName, | ||
ids: string[] | number[] | ||
) => { | ||
return deleteResourceItems(client, model, ids); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { linksByDay, linksByDomain, newDigestByMonth, newUsersByMonth } from "@/lib/adminQueries"; | ||
import { Digest, Team } from "@prisma/client"; | ||
import { Card, Col, Grid, Metric, Text } from "@tremor/react"; | ||
import DataOverTime from "./widgets/DataOverTime"; | ||
import LinksByWebsite from "./widgets/LinksByWebsite"; | ||
import LinksOverTime from "./widgets/LinksOverTime"; | ||
|
||
|
||
export type DashboardProps = { | ||
newUsersByMonth: Awaited<ReturnType<typeof newUsersByMonth>>; | ||
newDigestByMonth: Awaited<ReturnType<typeof newDigestByMonth>>; | ||
linksByDomain: Awaited<ReturnType<typeof linksByDomain>>; | ||
linksCount: number; | ||
latestTeam: Team | null; | ||
latestDigest: Digest | null; | ||
linksByDay: Awaited<ReturnType<typeof linksByDay>>; | ||
}; | ||
|
||
const Dashboard = (dashboardProps: DashboardProps) => { | ||
return ( | ||
<Grid numItems={1} numItemsSm={2} numItemsLg={3} className="gap-2"> | ||
<Col numColSpan={1} numColSpanLg={2}> | ||
<DataOverTime | ||
data={{ | ||
newUsersByMonth: dashboardProps?.newUsersByMonth, | ||
newDigestByMonth: dashboardProps?.newDigestByMonth, | ||
}} | ||
/> | ||
</Col> | ||
<LinksByWebsite data={dashboardProps.linksByDomain} /> | ||
<Col> | ||
<Card> | ||
<Text>Dernier digest publié</Text> | ||
<Metric> | ||
<a | ||
// @ts-expect-error | ||
href={`${dashboardProps.latestDigest?.team?.slug}/${dashboardProps.latestDigest?.slug}`} | ||
target="_blank" | ||
> | ||
{dashboardProps.latestDigest?.title} par {/* @ts-ignore */} | ||
{dashboardProps.latestDigest?.team.name} | ||
</a> | ||
</Metric> | ||
</Card> | ||
</Col> | ||
<Card> | ||
<Text>Dernière team créée</Text> | ||
<Metric> | ||
<a href={`${dashboardProps.latestTeam?.slug}`} target="_blank"> | ||
{dashboardProps.latestTeam?.name} | ||
</a> | ||
</Metric> | ||
</Card> | ||
<Card> | ||
<Text>Total des liens</Text> | ||
<Metric>{dashboardProps?.linksCount}</Metric> | ||
</Card> | ||
<Col numColSpan={3} numColSpanLg={3}> | ||
<LinksOverTime data={{ linksByDay: dashboardProps.linksByDay }} /> | ||
</Col> | ||
</Grid> | ||
) | ||
} | ||
|
||
export default Dashboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.