Compare commits
No commits in common. "6506917ddbe1caeb2eb8293edd89e575b887823e" and "f67ebbd98a1365b76e69128f5903eadc0658e34f" have entirely different histories.
6506917ddb
...
f67ebbd98a
|
@ -1,10 +1,10 @@
|
||||||
import { useState } from "react";
|
|
||||||
import { BaseRecord } from "@refinedev/core";
|
|
||||||
import { useTable } from "@refinedev/react-table";
|
|
||||||
import {
|
import {
|
||||||
ColumnDef,
|
ColumnDef,
|
||||||
flexRender,
|
flexRender,
|
||||||
} from "@tanstack/react-table";
|
getCoreRowModel,
|
||||||
|
useReactTable,
|
||||||
|
getPaginationRowModel,
|
||||||
|
} from "@tanstack/react-table"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
|
@ -16,23 +16,20 @@ import {
|
||||||
} from "./ui/table"
|
} from "./ui/table"
|
||||||
import { DataTablePagination } from "./table-pagination"
|
import { DataTablePagination } from "./table-pagination"
|
||||||
|
|
||||||
interface DataTableProps<TData extends BaseRecord = BaseRecord, TValue = unknown> {
|
interface DataTableProps<TData, TValue> {
|
||||||
columns: ColumnDef<TData, TValue>[]
|
columns: ColumnDef<TData, TValue>[]
|
||||||
|
data: TData[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DataTable<TData extends BaseRecord, TValue>({
|
export function DataTable<TData, TValue>({
|
||||||
columns
|
columns,
|
||||||
|
data,
|
||||||
}: DataTableProps<TData, TValue>) {
|
}: DataTableProps<TData, TValue>) {
|
||||||
const [hoveredRowId, setHoveredRowId] = useState<string>("");
|
const table = useReactTable({
|
||||||
|
data,
|
||||||
const table = useTable({
|
|
||||||
columns,
|
columns,
|
||||||
meta: {
|
getCoreRowModel: getCoreRowModel(),
|
||||||
hoveredRowId,
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
},
|
|
||||||
refineCoreProps: {
|
|
||||||
resource: "files"
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -43,7 +40,7 @@ export function DataTable<TData extends BaseRecord, TValue>({
|
||||||
<TableRow key={headerGroup.id}>
|
<TableRow key={headerGroup.id}>
|
||||||
{headerGroup.headers.map((header) => {
|
{headerGroup.headers.map((header) => {
|
||||||
return (
|
return (
|
||||||
<TableHead key={header.id} style={{ width: header.getSize() }}>
|
<TableHead key={header.id}>
|
||||||
{header.isPlaceholder
|
{header.isPlaceholder
|
||||||
? null
|
? null
|
||||||
: flexRender(
|
: flexRender(
|
||||||
|
@ -62,10 +59,6 @@ export function DataTable<TData extends BaseRecord, TValue>({
|
||||||
<TableRow
|
<TableRow
|
||||||
key={row.id}
|
key={row.id}
|
||||||
data-state={row.getIsSelected() && "selected"}
|
data-state={row.getIsSelected() && "selected"}
|
||||||
onMouseEnter={() => {
|
|
||||||
console.log(hoveredRowId, row.id);
|
|
||||||
setHoveredRowId(row.id)
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{row.getVisibleCells().map((cell) => (
|
{row.getVisibleCells().map((cell) => (
|
||||||
<TableCell key={cell.id}>
|
<TableCell key={cell.id}>
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { useUppy } from "./lib/uppy";
|
||||||
import type { UppyFile } from "@uppy/core";
|
import type { UppyFile } from "@uppy/core";
|
||||||
import { Progress } from "~/components/ui/progress";
|
import { Progress } from "~/components/ui/progress";
|
||||||
import { DialogClose } from "@radix-ui/react-dialog";
|
import { DialogClose } from "@radix-ui/react-dialog";
|
||||||
import { ChevronDownIcon, ExitIcon, TrashIcon } from "@radix-ui/react-icons";
|
import { ChevronDownIcon, TrashIcon } from "@radix-ui/react-icons";
|
||||||
import {
|
import {
|
||||||
ClockIcon,
|
ClockIcon,
|
||||||
DriveIcon,
|
DriveIcon,
|
||||||
|
@ -25,17 +25,12 @@ import {
|
||||||
PageIcon,
|
PageIcon,
|
||||||
ThemeIcon,
|
ThemeIcon,
|
||||||
} from "./icons";
|
} from "./icons";
|
||||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem } from "./ui/dropdown-menu";
|
import { DropdownMenu, DropdownMenuTrigger } from "./ui/dropdown-menu";
|
||||||
import { Avatar } from "@radix-ui/react-avatar";
|
import { Avatar } from "@radix-ui/react-avatar";
|
||||||
import { cn } from "~/utils";
|
import { cn } from "~/utils";
|
||||||
import { useGetIdentity, useLogout } from "@refinedev/core";
|
|
||||||
import { Identity } from "~/data/auth-provider";
|
|
||||||
|
|
||||||
|
|
||||||
export const GeneralLayout = ({ children }: React.PropsWithChildren<{}>) => {
|
export const GeneralLayout = ({ children }: React.PropsWithChildren<{}>) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { data: identity } = useGetIdentity<Identity>();
|
|
||||||
const{ mutate: logout } = useLogout()
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex flex-row">
|
<div className="h-full flex flex-row">
|
||||||
<header className="p-10 pr-0 flex flex-col w-[240px] h-full scroll-m-0 overflow-hidden">
|
<header className="p-10 pr-0 flex flex-col w-[240px] h-full scroll-m-0 overflow-hidden">
|
||||||
|
@ -100,18 +95,10 @@ export const GeneralLayout = ({ children }: React.PropsWithChildren<{}>) => {
|
||||||
<DropdownMenuTrigger>
|
<DropdownMenuTrigger>
|
||||||
<Button className="border rounded-full h-auto p-2 gap-x-2 text-ring font-semibold">
|
<Button className="border rounded-full h-auto p-2 gap-x-2 text-ring font-semibold">
|
||||||
<Avatar className="bg-ring h-7 w-7 rounded-full" />
|
<Avatar className="bg-ring h-7 w-7 rounded-full" />
|
||||||
{`${identity?.firstName} ${identity?.lastName}`}
|
whirly10
|
||||||
<ChevronDownIcon />
|
<ChevronDownIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
<DropdownMenuGroup>
|
|
||||||
<DropdownMenuItem onClick={() => logout()}>
|
|
||||||
<ExitIcon className="mr-2" />
|
|
||||||
Log Out
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuGroup>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ const DropdownMenuContent = React.forwardRef<
|
||||||
ref={ref}
|
ref={ref}
|
||||||
sideOffset={sideOffset}
|
sideOffset={sideOffset}
|
||||||
className={cn(
|
className={cn(
|
||||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-primary p-1 text-white shadow-md",
|
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
||||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
@ -80,17 +80,14 @@ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
||||||
const DropdownMenuItem = React.forwardRef<
|
const DropdownMenuItem = React.forwardRef<
|
||||||
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
||||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||||
inset?: boolean,
|
inset?: boolean
|
||||||
variant?: string
|
|
||||||
}
|
}
|
||||||
>(({ className, inset, variant, ...props }, ref) => (
|
>(({ className, inset, ...props }, ref) => (
|
||||||
<DropdownMenuPrimitive.Item
|
<DropdownMenuPrimitive.Item
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative flex cursor-default select-none items-center rounded-md px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||||
inset && "pl-8",
|
inset && "pl-8",
|
||||||
!variant && "focus:bg-primary-2/50 focus:text-primary-2-foreground",
|
|
||||||
variant === "destructive" && "focus:bg-destructive/50 focus:text-white",
|
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
@ -168,7 +165,7 @@ const DropdownMenuSeparator = React.forwardRef<
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<DropdownMenuPrimitive.Separator
|
<DropdownMenuPrimitive.Separator
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn("-mx-1 my-1 h-px bg-primary-2/75", className)}
|
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import { useGetIdentity } from "@refinedev/core"
|
|
||||||
import { Identity } from "~/data/auth-provider"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CrownIcon,
|
CrownIcon,
|
||||||
PersonIcon,
|
PersonIcon,
|
||||||
|
@ -13,14 +10,13 @@ import { Avatar } from "./ui/avatar"
|
||||||
import { Button } from "./ui/button"
|
import { Button } from "./ui/button"
|
||||||
|
|
||||||
export const UpgradeAccountBanner = () => {
|
export const UpgradeAccountBanner = () => {
|
||||||
const { data: identity } = useGetIdentity<Identity>();
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between p-8 border border-ring rounded-lg bg-secondary-1">
|
<div className="flex items-center justify-between p-8 border border-ring rounded-lg bg-secondary-1">
|
||||||
<div className="flex items-center gap-x-4">
|
<div className="flex items-center gap-x-4">
|
||||||
<Avatar className="border-2 border-ring h-20 w-20" />
|
<Avatar className="border-2 border-ring h-20 w-20" />
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center gap-x-2 font-bold">
|
<div className="flex items-center gap-x-2 font-bold">
|
||||||
{`${identity?.firstName} ${identity?.lastName}`}
|
wirtly
|
||||||
<CrownIcon className="text-ring" />
|
<CrownIcon className="text-ring" />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-x-5 mt-2">
|
<div className="flex gap-x-5 mt-2">
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
import type { DataProvider } from "@refinedev/core";
|
import type { BaseRecord, CreateManyParams, CreateManyResponse, CreateParams, CreateResponse, CustomParams, CustomResponse, DataProvider, DeleteManyParams, DeleteManyResponse, DeleteOneParams, DeleteOneResponse, GetListParams, GetListResponse, GetManyParams, GetManyResponse, GetOneParams, GetOneResponse, UpdateManyParams, UpdateManyResponse, UpdateParams, UpdateResponse } from "@refinedev/core";
|
||||||
|
|
||||||
export const defaultProvider: DataProvider = {
|
export class PortalFilesProvider implements DataProvider {
|
||||||
getList: () => { throw Error("Not Implemented") },
|
getList: <TData extends BaseRecord = BaseRecord>(params: GetListParams) => Promise<GetListResponse<TData>>;
|
||||||
getOne: () => { throw Error("Not Implemented") },
|
getMany?: (<TData extends BaseRecord = BaseRecord>(params: GetManyParams) => Promise<GetManyResponse<TData>>) | undefined;
|
||||||
update: () => { throw Error("Not Implemented") },
|
getOne: <TData extends BaseRecord = BaseRecord>(params: GetOneParams) => Promise<GetOneResponse<TData>>;
|
||||||
create: () => { throw Error("Not Implemented") },
|
create: <TData extends BaseRecord = BaseRecord, TVariables = {}>(params: CreateParams<TVariables>) => Promise<CreateResponse<TData>>;
|
||||||
deleteOne: () => { throw Error("Not Implemented") },
|
createMany?: (<TData extends BaseRecord = BaseRecord, TVariables = {}>(params: CreateManyParams<TVariables>) => Promise<CreateManyResponse<TData>>) | undefined;
|
||||||
getApiUrl: () => "",
|
update: <TData extends BaseRecord = BaseRecord, TVariables = {}>(params: UpdateParams<TVariables>) => Promise<UpdateResponse<TData>>;
|
||||||
|
updateMany?: (<TData extends BaseRecord = BaseRecord, TVariables = {}>(params: UpdateManyParams<TVariables>) => Promise<UpdateManyResponse<TData>>) | undefined;
|
||||||
|
deleteOne: <TData extends BaseRecord = BaseRecord, TVariables = {}>(params: DeleteOneParams<TVariables>) => Promise<DeleteOneResponse<TData>>;
|
||||||
|
deleteMany?: (<TData extends BaseRecord = BaseRecord, TVariables = {}>(params: DeleteManyParams<TVariables>) => Promise<DeleteManyResponse<TData>>) | undefined;
|
||||||
|
getApiUrl: () => string;
|
||||||
|
custom?: (<TData extends BaseRecord = BaseRecord, TQuery = unknown, TPayload = unknown>(params: CustomParams<TQuery, TPayload>) => Promise<CustomResponse<...>>) | undefined;
|
||||||
}
|
}
|
|
@ -14,7 +14,6 @@ import '@fontsource-variable/manrope';
|
||||||
import {Refine} from "@refinedev/core";
|
import {Refine} from "@refinedev/core";
|
||||||
import {PortalAuthProvider} from "~/data/auth-provider.js";
|
import {PortalAuthProvider} from "~/data/auth-provider.js";
|
||||||
import routerProvider from "@refinedev/remix-router";
|
import routerProvider from "@refinedev/remix-router";
|
||||||
import { defaultProvider } from "./data/file-provider";
|
|
||||||
|
|
||||||
export const links: LinksFunction = () => [
|
export const links: LinksFunction = () => [
|
||||||
{ rel: "stylesheet", href: stylesheet },
|
{ rel: "stylesheet", href: stylesheet },
|
||||||
|
@ -43,11 +42,6 @@ export default function App() {
|
||||||
<Refine
|
<Refine
|
||||||
authProvider={PortalAuthProvider.create("https://alpha.pinner.xyz")}
|
authProvider={PortalAuthProvider.create("https://alpha.pinner.xyz")}
|
||||||
routerProvider={routerProvider}
|
routerProvider={routerProvider}
|
||||||
dataProvider={defaultProvider}
|
|
||||||
resources={[
|
|
||||||
{ name: 'files' },
|
|
||||||
{ name: 'users' }
|
|
||||||
]}
|
|
||||||
>
|
>
|
||||||
<Outlet/>
|
<Outlet/>
|
||||||
</Refine>
|
</Refine>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { getFormProps, useForm } from "@conform-to/react";
|
import { getFormProps, useForm } from "@conform-to/react";
|
||||||
import { getZodConstraint, parseWithZod } from "@conform-to/zod";
|
import { getZodConstraint, parseWithZod } from "@conform-to/zod";
|
||||||
import { BaseKey, useGetIdentity, useUpdate, useUpdatePassword } from "@refinedev/core";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { Field } from "~/components/forms";
|
import { Field } from "~/components/forms";
|
||||||
|
@ -20,7 +19,10 @@ import { UsageCard } from "~/components/usage-card";
|
||||||
import QRImg from "~/images/QR.png";
|
import QRImg from "~/images/QR.png";
|
||||||
|
|
||||||
export default function MyAccount() {
|
export default function MyAccount() {
|
||||||
const { data: identity } = useGetIdentity<{ email: string }>();
|
const isLogged = true;
|
||||||
|
if (!isLogged) {
|
||||||
|
window.location.href = "/login";
|
||||||
|
}
|
||||||
|
|
||||||
const [openModal, setModal] = useState({
|
const [openModal, setModal] = useState({
|
||||||
changeEmail: false,
|
changeEmail: false,
|
||||||
|
@ -51,7 +53,7 @@ export default function MyAccount() {
|
||||||
<ManagementCard>
|
<ManagementCard>
|
||||||
<ManagementCardTitle>Email Address</ManagementCardTitle>
|
<ManagementCardTitle>Email Address</ManagementCardTitle>
|
||||||
<ManagementCardContent className="text-ring font-semibold">
|
<ManagementCardContent className="text-ring font-semibold">
|
||||||
{identity?.email}
|
bsimpson@springfield.oh.gov.com
|
||||||
</ManagementCardContent>
|
</ManagementCardContent>
|
||||||
<ManagementCardFooter>
|
<ManagementCardFooter>
|
||||||
<Button className="h-12 gap-x-2" onClick={() => setModal({ ...openModal, changeEmail: true })}>
|
<Button className="h-12 gap-x-2" onClick={() => setModal({ ...openModal, changeEmail: true })}>
|
||||||
|
@ -152,7 +154,7 @@ export default function MyAccount() {
|
||||||
setOpen={(value: boolean) =>
|
setOpen={(value: boolean) =>
|
||||||
setModal({ ...openModal, changeEmail: value })
|
setModal({ ...openModal, changeEmail: value })
|
||||||
}
|
}
|
||||||
currentValue={identity?.email || ""}
|
currentValue="bsimpson@springfield.oh.gov.com"
|
||||||
/>
|
/>
|
||||||
<ChangePasswordForm
|
<ChangePasswordForm
|
||||||
open={openModal.changePassword}
|
open={openModal.changePassword}
|
||||||
|
@ -174,16 +176,6 @@ const ChangeEmailSchema = z.object({
|
||||||
email: z.string().email(),
|
email: z.string().email(),
|
||||||
password: z.string(),
|
password: z.string(),
|
||||||
retypePassword: z.string(),
|
retypePassword: z.string(),
|
||||||
})
|
|
||||||
.superRefine((data, ctx) => {
|
|
||||||
if (data.password !== data.retypePassword) {
|
|
||||||
return ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
path: ["retypePassword"],
|
|
||||||
message: "Passwords do not match",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const ChangeEmailForm = ({
|
const ChangeEmailForm = ({
|
||||||
|
@ -195,8 +187,6 @@ const ChangeEmailForm = ({
|
||||||
setOpen: (value: boolean) => void;
|
setOpen: (value: boolean) => void;
|
||||||
currentValue: string;
|
currentValue: string;
|
||||||
}) => {
|
}) => {
|
||||||
const{ data: identity } = useGetIdentity<{ id: BaseKey }>();
|
|
||||||
const { mutate: updateEmail } = useUpdate();
|
|
||||||
const [form, fields] = useForm({
|
const [form, fields] = useForm({
|
||||||
id: "login",
|
id: "login",
|
||||||
constraint: getZodConstraint(ChangeEmailSchema),
|
constraint: getZodConstraint(ChangeEmailSchema),
|
||||||
|
@ -204,19 +194,6 @@ const ChangeEmailForm = ({
|
||||||
return parseWithZod(formData, { schema: ChangeEmailSchema });
|
return parseWithZod(formData, { schema: ChangeEmailSchema });
|
||||||
},
|
},
|
||||||
shouldValidate: "onSubmit",
|
shouldValidate: "onSubmit",
|
||||||
onSubmit(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const data = Object.fromEntries(new FormData(e.currentTarget).entries());
|
|
||||||
console.log(identity);
|
|
||||||
updateEmail({
|
|
||||||
resource: 'users',
|
|
||||||
id: identity?.id || "",
|
|
||||||
values: {
|
|
||||||
email: data.email.toString()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -259,16 +236,6 @@ const ChangePasswordSchema = z.object({
|
||||||
currentPassword: z.string().email(),
|
currentPassword: z.string().email(),
|
||||||
newPassword: z.string(),
|
newPassword: z.string(),
|
||||||
retypePassword: z.string(),
|
retypePassword: z.string(),
|
||||||
})
|
|
||||||
.superRefine((data, ctx) => {
|
|
||||||
if (data.newPassword !== data.retypePassword) {
|
|
||||||
return ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
path: ["retypePassword"],
|
|
||||||
message: "Passwords do not match",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const ChangePasswordForm = ({
|
const ChangePasswordForm = ({
|
||||||
|
@ -278,7 +245,6 @@ const ChangePasswordForm = ({
|
||||||
open: boolean;
|
open: boolean;
|
||||||
setOpen: (value: boolean) => void;
|
setOpen: (value: boolean) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const { mutate: updatePassword } = useUpdatePassword<{ password: string }>();
|
|
||||||
const [form, fields] = useForm({
|
const [form, fields] = useForm({
|
||||||
id: "login",
|
id: "login",
|
||||||
constraint: getZodConstraint(ChangeEmailSchema),
|
constraint: getZodConstraint(ChangeEmailSchema),
|
||||||
|
@ -286,16 +252,6 @@ const ChangePasswordForm = ({
|
||||||
return parseWithZod(formData, { schema: ChangePasswordSchema });
|
return parseWithZod(formData, { schema: ChangePasswordSchema });
|
||||||
},
|
},
|
||||||
shouldValidate: "onSubmit",
|
shouldValidate: "onSubmit",
|
||||||
onSubmit(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const data = Object.fromEntries(new FormData(e.currentTarget).entries());
|
|
||||||
|
|
||||||
updatePassword({
|
|
||||||
password: data.newPassword.toString()
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -314,7 +270,7 @@ const ChangePasswordForm = ({
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
inputProps={{ name: fields.newPassword.name, type: "password" }}
|
inputProps={{ name: fields.newPassword.name, type: "password" }}
|
||||||
labelProps={{ children: "New Password" }}
|
labelProps={{ children: "Password" }}
|
||||||
errors={fields.newPassword.errors}
|
errors={fields.newPassword.errors}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { DrawingPinIcon, TrashIcon } from "@radix-ui/react-icons";
|
import type { ColumnDef } from "@tanstack/react-table";
|
||||||
import type { ColumnDef, RowData } from "@tanstack/react-table";
|
|
||||||
import { FileIcon, MoreIcon } from "~/components/icons";
|
import { FileIcon, MoreIcon } from "~/components/icons";
|
||||||
import { Checkbox } from "~/components/ui/checkbox";
|
import { Checkbox } from "~/components/ui/checkbox";
|
||||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "~/components/ui/dropdown-menu";
|
|
||||||
|
|
||||||
// This type is used to define the shape of our data.
|
// This type is used to define the shape of our data.
|
||||||
// You can use a Zod schema here if you want.
|
// You can use a Zod schema here if you want.
|
||||||
|
@ -13,16 +11,9 @@ export type File = {
|
||||||
createdOn: string;
|
createdOn: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare module '@tanstack/table-core' {
|
|
||||||
interface TableMeta<TData extends RowData> {
|
|
||||||
hoveredRowId: string,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const columns: ColumnDef<File>[] = [
|
export const columns: ColumnDef<File>[] = [
|
||||||
{
|
{
|
||||||
id: "select",
|
id: "select",
|
||||||
size: 20,
|
|
||||||
header: ({ table }) => (
|
header: ({ table }) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
|
||||||
|
@ -64,31 +55,11 @@ export const columns: ColumnDef<File>[] = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "createdOn",
|
accessorKey: "createdOn",
|
||||||
size: 200,
|
|
||||||
header: "Created On",
|
header: "Created On",
|
||||||
cell: ({ row, table }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
{row.getValue("createdOn")}
|
{row.getValue("createdOn")}
|
||||||
{(row.getIsSelected() || table.options.meta?.hoveredRowId === row.id) && (
|
{row.getIsSelected() && <MoreIcon />}
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger>
|
|
||||||
<MoreIcon />
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
<DropdownMenuGroup>
|
|
||||||
<DropdownMenuItem>
|
|
||||||
<DrawingPinIcon className="mr-2" />
|
|
||||||
Ping CID
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<DropdownMenuItem variant="destructive">
|
|
||||||
<TrashIcon className="mr-2" />
|
|
||||||
Delete
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuGroup>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,11 @@ import { Button } from "~/components/ui/button";
|
||||||
import { AddIcon } from "~/components/icons";
|
import { AddIcon } from "~/components/icons";
|
||||||
|
|
||||||
export default function FileManager() {
|
export default function FileManager() {
|
||||||
|
const isLogged = true;
|
||||||
|
if (!isLogged) {
|
||||||
|
window.location.href = "/login";
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GeneralLayout>
|
<GeneralLayout>
|
||||||
<h1 className="font-bold mb-4 text-lg">File Manager</h1>
|
<h1 className="font-bold mb-4 text-lg">File Manager</h1>
|
||||||
|
@ -55,6 +60,20 @@ export default function FileManager() {
|
||||||
</div>
|
</div>
|
||||||
<DataTable
|
<DataTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
data={[
|
||||||
|
{
|
||||||
|
name: "whirly-final-draft.psd",
|
||||||
|
cid: "0xB45165ED3CD437B",
|
||||||
|
size: "1.89 MB",
|
||||||
|
createdOn: "03/02/2024 at 13:29 PM",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "whirly-final-draft.psd",
|
||||||
|
cid: "0xB45165ED3CD437B",
|
||||||
|
size: "1.89 MB",
|
||||||
|
createdOn: "03/02/2024 at 13:29 PM",
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
</GeneralLayout>
|
</GeneralLayout>
|
||||||
);
|
);
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
"@refinedev/core": "https://gitpkg.now.sh/LumeWeb/refine/packages/core?remix",
|
"@refinedev/core": "https://gitpkg.now.sh/LumeWeb/refine/packages/core?remix",
|
||||||
"@refinedev/devtools-internal": "https://gitpkg.now.sh/LumeWeb/refine/packages/devtools-internal?remix",
|
"@refinedev/devtools-internal": "https://gitpkg.now.sh/LumeWeb/refine/packages/devtools-internal?remix",
|
||||||
"@refinedev/devtools-shared": "https://gitpkg.now.sh/LumeWeb/refine/packages/devtools-shared?remix",
|
"@refinedev/devtools-shared": "https://gitpkg.now.sh/LumeWeb/refine/packages/devtools-shared?remix",
|
||||||
"@refinedev/react-table": "https://gitpkg.now.sh/LumeWeb/refine/packages/react-table?remix",
|
|
||||||
"@refinedev/remix-router": "https://gitpkg.now.sh/LumeWeb/refine/packages/remix?remix",
|
"@refinedev/remix-router": "https://gitpkg.now.sh/LumeWeb/refine/packages/remix?remix",
|
||||||
"@remix-run/node": "^2.8.0",
|
"@remix-run/node": "^2.8.0",
|
||||||
"@remix-run/react": "^2.8.0",
|
"@remix-run/react": "^2.8.0",
|
||||||
|
|
Loading…
Reference in New Issue