-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from wri/epic/TM-853-admin-ui
[TM-853] Admin UI Epic
- Loading branch information
Showing
14 changed files
with
561 additions
and
171 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,21 +1,39 @@ | ||
import { Divider, Stack, Typography } from "@mui/material"; | ||
import { BooleanField, Datagrid, ImageField, List, TextField } from "react-admin"; | ||
import { Stack } from "@mui/material"; | ||
import { useState } from "react"; | ||
import { BooleanField, Datagrid, ImageField, List, TextField, useDataProvider } from "react-admin"; | ||
|
||
export const FormList = () => ( | ||
<> | ||
<Stack gap={1} py={2}> | ||
<Typography variant="h5">Forms</Typography> | ||
import { UserDataProvider } from "@/admin/apiProvider/dataProviders/userDataProvider"; | ||
import ListActionsCreate from "@/admin/components/Actions/ListActionsCreate"; | ||
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert"; | ||
import Text from "@/components/elements/Text/Text"; | ||
|
||
<Divider /> | ||
</Stack> | ||
import modules from "../.."; | ||
|
||
<List> | ||
<Datagrid rowClick="show" bulkActionButtons={false}> | ||
<ImageField source="banner.thumb_url" label="Banner Image" /> | ||
<TextField source="title" label="Title" /> | ||
<TextField source="type" label="Form Type" /> | ||
<BooleanField source="published" label="Published" /> | ||
</Datagrid> | ||
</List> | ||
</> | ||
); | ||
export const FormList = () => { | ||
const [exporting, setExporting] = useState<boolean>(false); | ||
const userDataProvider = useDataProvider<UserDataProvider>(); | ||
const handleExport = () => { | ||
setExporting(true); | ||
|
||
userDataProvider.export(modules.user.ResourceName).finally(() => setExporting(false)); | ||
}; | ||
return ( | ||
<> | ||
<Stack gap={1} className="pb-6"> | ||
<Text variant="text-36-bold" className="leading-none"> | ||
Forms | ||
</Text> | ||
</Stack> | ||
|
||
<List actions={<ListActionsCreate onExport={handleExport} />}> | ||
<Datagrid rowClick="show" bulkActionButtons={false}> | ||
<ImageField source="banner.thumb_url" label="Banner Image" /> | ||
<TextField source="title" label="Title" /> | ||
<TextField source="type" label="Form Type" /> | ||
<BooleanField source="published" label="Published" /> | ||
</Datagrid> | ||
</List> | ||
<ExportProcessingAlert show={exporting} /> | ||
</> | ||
); | ||
}; |
51 changes: 41 additions & 10 deletions
51
src/admin/modules/fundingProgrammes/components/FundingProgrammeList.tsx
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,25 +1,56 @@ | ||
import { Divider, Stack, Typography } from "@mui/material"; | ||
import { Datagrid, DateField, EditButton, List, ShowButton, TextField } from "react-admin"; | ||
import { Stack } from "@mui/material"; | ||
import { useState } from "react"; | ||
import { Datagrid, DateField, EditButton, List, ShowButton, TextField, useDataProvider } from "react-admin"; | ||
|
||
import { UserDataProvider } from "@/admin/apiProvider/dataProviders/userDataProvider"; | ||
import ListActionsCreate from "@/admin/components/Actions/ListActionsCreate"; | ||
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert"; | ||
import Menu from "@/components/elements/Menu/Menu"; | ||
import { MENU_PLACEMENT_BOTTOM_LEFT } from "@/components/elements/Menu/MenuVariant"; | ||
import Text from "@/components/elements/Text/Text"; | ||
import Icon, { IconNames } from "@/components/extensive/Icon/Icon"; | ||
|
||
import modules from "../.."; | ||
|
||
const tableMenu = [ | ||
{ | ||
id: "1", | ||
render: () => <EditButton /> | ||
}, | ||
{ | ||
id: "2", | ||
render: () => <ShowButton /> | ||
} | ||
]; | ||
|
||
export const FundingProgrammeList = () => { | ||
const [exporting, setExporting] = useState<boolean>(false); | ||
const userDataProvider = useDataProvider<UserDataProvider>(); | ||
const handleExport = () => { | ||
setExporting(true); | ||
|
||
userDataProvider.export(modules.user.ResourceName).finally(() => setExporting(false)); | ||
}; | ||
return ( | ||
<> | ||
<Stack gap={1} py={2}> | ||
<Typography variant="h5">Funding Programmes</Typography> | ||
|
||
<Divider /> | ||
<Stack gap={1} className="pb-6"> | ||
<Text variant="text-36-bold" className="leading-none"> | ||
Funding Programmes | ||
</Text> | ||
</Stack> | ||
|
||
<List filters={[]}> | ||
<Datagrid rowClick="edit"> | ||
<List actions={<ListActionsCreate onExport={handleExport} />} filters={[]}> | ||
<Datagrid> | ||
<TextField source="name" label="Name" sortable={false} /> | ||
<TextField source="description" label="Description" sortable={false} /> | ||
<TextField source="status" label="Status" sortable={false} sx={{ textTransform: "capitalize" }} /> | ||
<DateField source="created_at" label="Date Added" sortable={false} locales="en-GB" /> | ||
<ShowButton /> | ||
<EditButton /> | ||
<Menu menu={tableMenu} placement={MENU_PLACEMENT_BOTTOM_LEFT}> | ||
<Icon name={IconNames.ELIPSES} className="h-6 w-6 rounded-full p-1 hover:bg-neutral-200"></Icon> | ||
</Menu> | ||
</Datagrid> | ||
</List> | ||
<ExportProcessingAlert show={exporting} /> | ||
</> | ||
); | ||
}; |
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.