add dev inputs
This commit is contained in:
@@ -4,6 +4,7 @@ import PageTitle from '@/app/ui/page-title';
|
|||||||
import UploadSectionFile from '@/app/components/upload-section-file';
|
import UploadSectionFile from '@/app/components/upload-section-file';
|
||||||
import { getAllowedFilesExtensions } from '@/app/actions/fileUpload';
|
import { getAllowedFilesExtensions } from '@/app/actions/fileUpload';
|
||||||
import {StackedBarChart} from '@/app/components/StackedBarChart';
|
import {StackedBarChart} from '@/app/components/StackedBarChart';
|
||||||
|
import {TestComponent} from '@/app/components/test-component';
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
@@ -40,6 +41,7 @@ export default async function Page() {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PageTitle title="image-protection" />
|
<PageTitle title="image-protection" />
|
||||||
|
<TestComponent/>
|
||||||
<div className="split-blocks">
|
<div className="split-blocks">
|
||||||
<ProtectionSummary fileType={FILE_TYPE}/>
|
<ProtectionSummary fileType={FILE_TYPE}/>
|
||||||
<div className="protection-overview">
|
<div className="protection-overview">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useTranslations } from 'next-intl';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { BarChart, Bar, Cell, XAxis, Tooltip } from 'recharts';
|
import { BarChart, Bar, Cell, XAxis, Tooltip } from 'recharts';
|
||||||
import { pluralize } from '@/app/lib/pluralize';
|
import { pluralize } from '@/app/lib/pluralize';
|
||||||
|
import { useStoreWithDevtools } from '@/app/stores/useStoreWithDevtools';
|
||||||
|
|
||||||
type Files = {
|
type Files = {
|
||||||
data: {
|
data: {
|
||||||
@@ -31,10 +32,13 @@ export const StackedBarChart = ({ data }: Files) => {
|
|||||||
const STROKE_COLOR = "#dfdede24";
|
const STROKE_COLOR = "#dfdede24";
|
||||||
const STROKE_WIDTH = 1;
|
const STROKE_WIDTH = 1;
|
||||||
|
|
||||||
const { totalChecks, totalViolations } = useMemo(() => ({
|
/* const { totalChecks, totalViolations } = useMemo(() => ({
|
||||||
totalChecks: data.reduce((sum, item) => sum + (item.checks || 0), 0),
|
totalChecks: data.reduce((sum, item) => sum + (item.checks || 0), 0),
|
||||||
totalViolations: data.reduce((sum, item) => sum + (item.violations || 0), 0)
|
totalViolations: data.reduce((sum, item) => sum + (item.violations || 0), 0)
|
||||||
}), [data]);
|
}), [data]); */
|
||||||
|
|
||||||
|
const totalChecks = useStoreWithDevtools(s => s.value1);
|
||||||
|
const totalViolations = useStoreWithDevtools(s => s.value2);
|
||||||
|
|
||||||
const renderBarWithPartialBorder = (props: BarShapeProps) => {
|
const renderBarWithPartialBorder = (props: BarShapeProps) => {
|
||||||
const { x, y, width, height, fill } = props;
|
const { x, y, width, height, fill } = props;
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useStoreWithDevtools } from '@/app/stores/useStoreWithDevtools';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
|
||||||
|
export function TestComponent() {
|
||||||
|
const t = useTranslations('Global');
|
||||||
|
|
||||||
|
const setText1 = useStoreWithDevtools(s => s.setValue1);
|
||||||
|
const setText2 = useStoreWithDevtools(s => s.setValue2);
|
||||||
|
const text1 = useStoreWithDevtools(s => s.value1);
|
||||||
|
const text2 = useStoreWithDevtools(s => s.value2);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mb-4">
|
||||||
|
<div className='mb-2'>
|
||||||
|
<input
|
||||||
|
className='border rounded-md mr-1'
|
||||||
|
type="text"
|
||||||
|
onChange={(e) => {
|
||||||
|
setText1(Number(e.target.value))
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span>{t('check')} {text1}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
className='border rounded-md mr-1'
|
||||||
|
type="text"
|
||||||
|
onChange={(e) => {
|
||||||
|
setText2(Number(e.target.value))
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span>{t('violation')} {text2}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -2,15 +2,27 @@ import { create } from 'zustand'
|
|||||||
import { devtools } from 'zustand/middleware'
|
import { devtools } from 'zustand/middleware'
|
||||||
|
|
||||||
interface Store {
|
interface Store {
|
||||||
value: any
|
value1: number
|
||||||
setValue: (value: any) => void
|
setValue1: (value: number) => void
|
||||||
|
value2: number
|
||||||
|
setValue2: (value: number) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useStoreWithDevtools = create<Store>()(
|
export const useStoreWithDevtools = create<Store>()(
|
||||||
devtools(
|
devtools(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
value: 0,
|
value1: 0,
|
||||||
setValue: (value) => set({ value }),
|
setValue1: (value) => {
|
||||||
|
if ((typeof value === 'number')) {
|
||||||
|
set({ value1: value })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
value2: 0,
|
||||||
|
setValue2: (value) => {
|
||||||
|
if ((typeof value === 'number')) {
|
||||||
|
set({ value2: value })
|
||||||
|
}
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: 'DevStore', // имя для DevTools
|
name: 'DevStore', // имя для DevTools
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { getUserFilesData } from '@/app/actions/fileEntity';
|
|
||||||
import { getUserFilesInfo } from '@/app/actions/action';
|
import { getUserFilesInfo } from '@/app/actions/action';
|
||||||
import { convertBytes } from '@/app/lib/convertBytes';
|
import { convertBytes } from '@/app/lib/convertBytes';
|
||||||
import { pluralize } from '@/app/lib/pluralize';
|
import { pluralize } from '@/app/lib/pluralize';
|
||||||
|
import { useStoreWithDevtools } from '@/app/stores/useStoreWithDevtools';
|
||||||
|
|
||||||
type FilesInfo = {
|
type FilesInfo = {
|
||||||
totalSize: number;
|
totalSize: number;
|
||||||
@@ -15,7 +15,9 @@ type FilesInfo = {
|
|||||||
|
|
||||||
export default function ProtectionSummary({ fileType }: { fileType: string }) {
|
export default function ProtectionSummary({ fileType }: { fileType: string }) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
console.log(fileType);
|
const CHECKS = useStoreWithDevtools(s => s.value1);
|
||||||
|
const VIOLATIONS = useStoreWithDevtools(s => s.value2);
|
||||||
|
|
||||||
|
|
||||||
const getFileTypeFields = (fileType: string): { totalSize: string, totalCount: string } => {
|
const getFileTypeFields = (fileType: string): { totalSize: string, totalCount: string } => {
|
||||||
switch (fileType) {
|
switch (fileType) {
|
||||||
@@ -85,9 +87,6 @@ export default function ProtectionSummary({ fileType }: { fileType: string }) {
|
|||||||
return pluralize(number, translate[0], translate[1], translate[2]);
|
return pluralize(number, translate[0], translate[1], translate[2]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const CHECKS = 6;
|
|
||||||
const VIOLATIONS = 2;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="protection-overview grow">
|
<div className="protection-overview grow">
|
||||||
<h3>{t('protecting-your-content')}</h3>
|
<h3>{t('protecting-your-content')}</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user