2023-09-29 12:29:22 +00:00
|
|
|
'use client';
|
2023-10-03 23:05:17 +00:00
|
|
|
import WebsitesTable from 'app/(main)/settings/websites/WebsitesTable';
|
2023-09-29 12:29:22 +00:00
|
|
|
import useUser from 'components/hooks/useUser';
|
|
|
|
|
import useApi from 'components/hooks/useApi';
|
|
|
|
|
import DataTable from 'components/common/DataTable';
|
|
|
|
|
import useFilterQuery from 'components/hooks/useFilterQuery';
|
|
|
|
|
import WebsitesHeader from './WebsitesHeader';
|
|
|
|
|
|
2023-10-04 08:46:00 +00:00
|
|
|
function useWebsites({ includeTeams, onlyTeams }) {
|
2023-09-29 12:29:22 +00:00
|
|
|
const { user } = useUser();
|
|
|
|
|
const { get } = useApi();
|
2023-10-04 08:46:00 +00:00
|
|
|
return useFilterQuery(
|
2023-09-29 12:29:22 +00:00
|
|
|
['websites', { includeTeams, onlyTeams }],
|
|
|
|
|
params => {
|
|
|
|
|
return get(`/users/${user?.id}/websites`, {
|
|
|
|
|
includeTeams,
|
|
|
|
|
onlyTeams,
|
|
|
|
|
...params,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
{ enabled: !!user },
|
|
|
|
|
);
|
2023-10-04 08:46:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function WebsitesDataTable({
|
|
|
|
|
showHeader = true,
|
|
|
|
|
showEditButton = true,
|
|
|
|
|
showViewButton = true,
|
|
|
|
|
showActions = true,
|
|
|
|
|
showTeam,
|
|
|
|
|
includeTeams,
|
|
|
|
|
onlyTeams,
|
|
|
|
|
children,
|
|
|
|
|
}) {
|
|
|
|
|
const queryResult = useWebsites({ includeTeams, onlyTeams });
|
2023-09-29 12:29:22 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{showHeader && <WebsitesHeader />}
|
2023-10-04 08:46:00 +00:00
|
|
|
<DataTable queryResult={queryResult}>
|
2023-09-29 12:29:22 +00:00
|
|
|
{({ data }) => (
|
2023-10-04 08:46:00 +00:00
|
|
|
<WebsitesTable
|
|
|
|
|
data={data}
|
|
|
|
|
showTeam={showTeam}
|
|
|
|
|
showActions={showActions}
|
|
|
|
|
showEditButton={showEditButton}
|
|
|
|
|
showViewButton={showViewButton}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</WebsitesTable>
|
2023-09-29 12:29:22 +00:00
|
|
|
)}
|
|
|
|
|
</DataTable>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-04 08:46:00 +00:00
|
|
|
export default WebsitesDataTable;
|