-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9568093
commit 4263426
Showing
21 changed files
with
299 additions
and
116 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
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
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
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,37 @@ | ||
import {Link, useSearchParams} from "react-router-dom"; | ||
import {useTranslation} from "react-i18next"; | ||
import {useCollectionAll} from "./hooks/useCollectionAll"; | ||
import {CollectionType} from "../../types/collection/CollectionType"; | ||
import _ from 'lodash'; | ||
|
||
export const ContentSidebar = (() => { | ||
const [t] = useTranslation("global"); | ||
const [searchParams] = useSearchParams() | ||
const collections_api_response = useCollectionAll() | ||
const collections: Array<CollectionType> = _.get(collections_api_response, 'data.data.data', []) | ||
return ( | ||
<> | ||
<div className="text-primary-500 font-semibold"> | ||
{t("collections")} | ||
</div> | ||
|
||
<ul className="mt-5"> | ||
{collections.map((collection: CollectionType) => { | ||
return ( | ||
<li key={collection.id}> | ||
<Link | ||
to={`/admin/content?type=${encodeURI(collection.identifier)}`} | ||
key={collection.identifier} | ||
className={`rounded block mt-3 p-3 text-sm cursor-pointer ${searchParams.get("type") === collection.identifier ? 'text-primary-600 font-semibold bg-gray-300' : ''} overflow-x-hidden`} | ||
> | ||
{collection.name} | ||
</Link> | ||
</li> | ||
) | ||
})} | ||
|
||
|
||
</ul> | ||
</> | ||
) | ||
}) |
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,42 @@ | ||
import {useTranslation} from "react-i18next"; | ||
import {ContentSidebar} from "./ContentSidebar"; | ||
import {Link, useSearchParams} from "react-router-dom"; | ||
import HasPermission from "../../components/HasPermission"; | ||
|
||
export const ContentTable = (() => { | ||
const [t] = useTranslation("global"); | ||
const [searchParams] = useSearchParams() | ||
const collectionType = searchParams.get("type") | ||
|
||
return ( | ||
<div className="flex w-full"> | ||
<div className="p-5 w-64 bg-gray-50 min-h-screen"> | ||
<ContentSidebar /> | ||
</div> | ||
<div className="p-5 flex-1"> | ||
{collectionType ? | ||
<div className="flex items-center w-full"> | ||
<div className="p-5 text-2xl font-semibold text-primary-500"> | ||
{t("collection type table title")} | ||
</div> | ||
<div className="ml-auto"> | ||
<HasPermission displayDenied={false} identifier="collection_create"> | ||
<Link | ||
className="bg-primary-600 py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500" | ||
to={encodeURI(`/admin/content-create?type=${collectionType}`)} | ||
> | ||
{t("create")} | ||
</Link> | ||
</HasPermission> | ||
</div> | ||
</div> | ||
: | ||
<> | ||
{t('please select a collection from sidebar to see the collections entries.')} | ||
</> | ||
} | ||
</div> | ||
</div> | ||
|
||
) | ||
}) |
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,25 @@ | ||
import {useQuery} from '@tanstack/react-query' | ||
import { useAxios } from '../../../hooks/useAxios' | ||
import _ from 'lodash' | ||
import {useNavigate} from 'react-router-dom' | ||
|
||
export const useCollectionAll = () => { | ||
|
||
const client = useAxios(); | ||
const redirect = useNavigate(); | ||
return useQuery({ | ||
queryKey: ['collection-all'], | ||
queryFn: (async () => { | ||
try { | ||
return await client.get("/collection-all") | ||
} catch (error) { | ||
if (_.get(error, 'response.status') === 401) { | ||
localStorage.removeItem('AUTH_TOKEN') | ||
redirect("/admin/login") | ||
} | ||
|
||
console.error(error) | ||
} | ||
}) | ||
}) | ||
} |
Oops, something went wrong.