Skip to content

Commit

Permalink
added icon only menu trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
indpurvesh committed Dec 27, 2024
1 parent a077502 commit 396f93a
Show file tree
Hide file tree
Showing 13 changed files with 889 additions and 909 deletions.
2 changes: 0 additions & 2 deletions react-admin/src/pages/admin-user/AdminUserEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function AdminUserEdit() {
};

return (
<div className="flex-1 bg-white">
<div className="px-5 pl-64">
<div className="w-full">
<div className="block rounded-lg p-6">
Expand Down Expand Up @@ -171,7 +170,6 @@ function AdminUserEdit() {
</div>
</div>
</div>
</div>
);
}

Expand Down
37 changes: 20 additions & 17 deletions react-admin/src/pages/admin-user/AdminUserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,30 @@ function AdminUserTable() {

return (
<>
<div className="flex items-center">
<div className="p-5 text-2xl font-semibold text-primary-500">
{t("admin_users")}
</div>
<HasPermission displayDenied={false} identifier="admin_user_create">
<Link
className="ml-auto 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="/admin/admin-user-create"
>
{t("create")}
</Link>
</HasPermission>
</div>
<div className="w-full block overflow-hidden">
<div className="overflow-x-scroll">
<HasPermission identifier="admin_user_table">
<AvoRedTable table={table}/>
<div className="p-5">
<div className="flex items-center">
<div className="p-5 text-2xl font-semibold text-primary-500">
{t("admin_users")}
</div>
<HasPermission displayDenied={false} identifier="admin_user_create">
<Link
className="ml-auto 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="/admin/admin-user-create"
>
{t("create")}
</Link>
</HasPermission>
</div>
<div className="w-full block overflow-hidden">
<div className="overflow-x-scroll">
<HasPermission identifier="admin_user_table">
<AvoRedTable table={table}/>
</HasPermission>
</div>
</div>
</div>
</>

);
}

Expand Down
218 changes: 108 additions & 110 deletions react-admin/src/pages/asset/AssetTable.tsx
Original file line number Diff line number Diff line change
@@ -1,134 +1,132 @@
import React, { useState } from "react";
import { useAssetTable } from "./hooks/useAssetTable";
import React, {useState} from "react";
import {useAssetTable} from "./hooks/useAssetTable";
import _ from "lodash";
import { useStoreAsset } from "./hooks/useStoreAsset";
import { useTranslation } from "react-i18next";
import { AssetSaveSchema } from "./schemas/asset.save.schema";
import { SubmitHandler, useForm } from "react-hook-form";
import { joiResolver } from "@hookform/resolvers/joi";
import {useStoreAsset} from "./hooks/useStoreAsset";
import {useTranslation} from "react-i18next";
import {AssetSaveSchema} from "./schemas/asset.save.schema";
import {SubmitHandler, useForm} from "react-hook-form";
import {joiResolver} from "@hookform/resolvers/joi";
import IAssetSave from "../../types/asset/IAssetSave";
import IAssetModel from "../../types/asset/IAssetModel";
import { AssetUploadModal } from "./AssetUploadModal";
import { DisplayAsset } from "./DisplayAsset";
import { CreateFolderModal } from "./CreateFolderModal";
import {AssetUploadModal} from "./AssetUploadModal";
import {DisplayAsset} from "./DisplayAsset";
import {CreateFolderModal} from "./CreateFolderModal";
import {useParams} from "react-router-dom";

function AssetTable() {
const [isUploadAssetModalOpen, setIsUploadAssetModalOpen] = useState(false);
const [isCreateFolderModalOpen, setIsCreateFolderModalOpen] = useState(false);
const [isUploadAssetModalOpen, setIsUploadAssetModalOpen] = useState(false);
const [isCreateFolderModalOpen, setIsCreateFolderModalOpen] = useState(false);

const params = useParams()
const asset_id: string = params.asset_id ?? ''
const params = useParams()
const asset_id: string = params.asset_id ?? ''

const asset_api_table_response = useAssetTable(asset_id);
const assets: Array<IAssetModel> = _.get(
asset_api_table_response,
"data.data.data",
[],
);
const asset_api_table_response = useAssetTable(asset_id);
const assets: Array<IAssetModel> = _.get(
asset_api_table_response,
"data.data.data",
[],
);

const { mutate } = useStoreAsset(asset_id);
const [t] = useTranslation("global");
const {mutate} = useStoreAsset(asset_id);
const [t] = useTranslation("global");

const {
register,
handleSubmit,
formState: { errors },
} = useForm({
resolver: joiResolver(AssetSaveSchema, { allowUnknown: true }),
});
const {
register,
handleSubmit,
formState: {errors},
} = useForm({
resolver: joiResolver(AssetSaveSchema, {allowUnknown: true}),
});

const openFolder = (e: React.MouseEvent<HTMLElement>, asset_id: string) => {
e.preventDefault();
console.log(asset_id);
};
const openFolder = (e: React.MouseEvent<HTMLElement>, asset_id: string) => {
e.preventDefault();
console.log(asset_id);
};

const onCloseCreateFolderModal = () => {
setIsCreateFolderModalOpen(false);
};
const onCloseCreateFolderModal = () => {
setIsCreateFolderModalOpen(false);
};

const openCreateFolderModal = () => {
setIsCreateFolderModalOpen(true);
};
const openCreateFolderModal = () => {
setIsCreateFolderModalOpen(true);
};

const onCloseUploadModal = () => {
setIsUploadAssetModalOpen(false);
};
const onCloseUploadModal = () => {
setIsUploadAssetModalOpen(false);
};

const openUploadAssetModal = () => {
setIsUploadAssetModalOpen(true);
};
const openUploadAssetModal = () => {
setIsUploadAssetModalOpen(true);
};

const submitHandler: SubmitHandler<IAssetSave> = (data: IAssetSave) => {
data.file = data.file_list ? data.file_list[0] : undefined;
onCloseUploadModal();
mutate(data);
};
const submitHandler: SubmitHandler<IAssetSave> = (data: IAssetSave) => {
data.file = data.file_list ? data.file_list[0] : undefined;
onCloseUploadModal();
mutate(data);
};

return (
<div className="flex-1 bg-white">
<div className="pl-64">
<div className="p-5 flex w-full items-center">
<div className="text-primary-500 text-2xl font-semibold">
{t("asset_table")}
</div>
<div className="ml-auto">
<button
type="button"
onClick={openUploadAssetModal}
className="bg-primary-500 rounded-md bg-black/20 px-4 py-2 text-sm font-medium text-white hover:bg-black/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75"
>
{t("upload_asset")}
</button>
<button
type="button"
onClick={openCreateFolderModal}
className="ml-3 bg-gray-400 rounded-md bg-black/20 px-4 py-2 text-sm font-medium text-white hover:bg-black/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75"
>
{t("create_folder")}
</button>
</div>
return (
<>
<div className="p-5 flex w-full items-center">
<div className="text-primary-500 text-2xl font-semibold">
{t("asset_table")}
</div>
<div className="ml-auto">
<button
type="button"
onClick={openUploadAssetModal}
className="bg-primary-500 rounded-md bg-black/20 px-4 py-2 text-sm font-medium text-white hover:bg-black/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75"
>
{t("upload_asset")}
</button>
<button
type="button"
onClick={openCreateFolderModal}
className="ml-3 bg-gray-400 rounded-md bg-black/20 px-4 py-2 text-sm font-medium text-white hover:bg-black/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75"
>
{t("create_folder")}
</button>
</div>

<div className="">
<AssetUploadModal
onCloseModal={onCloseUploadModal}
isOpen={isUploadAssetModalOpen}
submitHandler={submitHandler}
handleSubmit={handleSubmit}
register={register}
/>
<CreateFolderModal
parent_id={asset_id}
onCloseModal={onCloseCreateFolderModal}
isOpen={isCreateFolderModalOpen}
/>
</div>
</div>
<div className="">
<AssetUploadModal
onCloseModal={onCloseUploadModal}
isOpen={isUploadAssetModalOpen}
submitHandler={submitHandler}
handleSubmit={handleSubmit}
register={register}
/>
<CreateFolderModal
parent_id={asset_id}
onCloseModal={onCloseCreateFolderModal}
isOpen={isCreateFolderModalOpen}
/>
</div>
</div>

<div className="mt-5">
<div className="px-4 mx-auto">
<div className="flex flex-col mt-6">
<div className="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div className="inline-block min-w-full p-2">
<div className="grid grid-cols-6 gap-4 mx-5">
{assets.map((asset: IAssetModel) => {
return (
<DisplayAsset
openFolder={openFolder}
key={asset.id}
asset={asset}
/>
);
})}
</div>
<div className="mt-5">
<div className="px-4 mx-auto">
<div className="flex flex-col mt-6">
<div className="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div className="inline-block min-w-full p-2">
<div className="grid grid-cols-6 gap-4 mx-5">
{assets.map((asset: IAssetModel) => {
return (
<DisplayAsset
openFolder={openFolder}
key={asset.id}
asset={asset}
/>
);
})}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
</>
);
}

export default AssetTable;
Loading

0 comments on commit 396f93a

Please sign in to comment.