Compare commits
2 Commits
e73d008431
...
02d723cc0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02d723cc0b | ||
|
|
0a68598c45 |
|
|
@ -71,6 +71,30 @@
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (width <= 570px) {
|
||||||
|
|
||||||
|
.report-tag-list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-tag {
|
||||||
|
> .report-tag-count-good {
|
||||||
|
color: var(--tag-color-good);
|
||||||
|
}
|
||||||
|
> .report-tag-count-ok {
|
||||||
|
color: var(--tag-color-ok);
|
||||||
|
}
|
||||||
|
> .report-tag-count-bad {
|
||||||
|
color: var(--tag-color-bad);
|
||||||
|
}
|
||||||
|
> .report-tag-count-very-bad {
|
||||||
|
color: var(--tag-color-very-bad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.report-comment:hover {
|
.report-comment:hover {
|
||||||
background-color: #383d49;
|
background-color: #383d49;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
|
|
||||||
|
|
@ -4,29 +4,46 @@ import NicknameList from "~/components/itemDialog/nicknameList";
|
||||||
import CommentsList from "~/components/itemDialog/commentsList";
|
import CommentsList from "~/components/itemDialog/commentsList";
|
||||||
import TagList from "~/components/itemDialog/tagList";
|
import TagList from "~/components/itemDialog/tagList";
|
||||||
import TitleHeader from "~/components/itemDialog/titleHeader";
|
import TitleHeader from "~/components/itemDialog/titleHeader";
|
||||||
|
import useWindowDimensions from "~/hooks/windowDimensions";
|
||||||
|
import trimLink from "~/functions/trimLink";
|
||||||
|
|
||||||
export default function ItemDialog({ blacklistItem, open, handleClose }: { blacklistItem: BlacklistItem|null, open: boolean, handleClose: Function }){
|
export default function ItemDialog({ blacklistItem, open, handleClose }: { blacklistItem: BlacklistItem|null, open: boolean, handleClose: Function }){
|
||||||
return (
|
if (blacklistItem){
|
||||||
<Dialog
|
const { width } = useWindowDimensions();
|
||||||
open={open}
|
return (
|
||||||
onClose={() => handleClose()}
|
<Dialog
|
||||||
>
|
open={open}
|
||||||
<DialogTitle>
|
onClose={() => handleClose()}
|
||||||
<TitleHeader name={blacklistItem?.link} handleClose={handleClose}/>
|
>
|
||||||
<TagList
|
<DialogTitle>
|
||||||
afk={blacklistItem?.afk}
|
<TitleHeader name={width < 570 ? trimLink(blacklistItem?.link) : blacklistItem?.link} handleClose={handleClose}/>
|
||||||
cheater={blacklistItem?.cheater}
|
<TagList
|
||||||
griefer={blacklistItem?.griefer}
|
afk={blacklistItem?.afk}
|
||||||
toxic={blacklistItem?.toxic}
|
cheater={blacklistItem?.cheater}
|
||||||
useless={blacklistItem?.useless}
|
griefer={blacklistItem?.griefer}
|
||||||
smurf={blacklistItem?.smurf}
|
toxic={blacklistItem?.toxic}
|
||||||
/>
|
useless={blacklistItem?.useless}
|
||||||
</DialogTitle>
|
smurf={blacklistItem?.smurf}
|
||||||
<Divider sx={{marginTop: '10px', marginBottom: '10px', alignSelf: 'center'}}/>
|
/>
|
||||||
<DialogContent>
|
</DialogTitle>
|
||||||
<NicknameList nicknames={blacklistItem?.nicknames}/>
|
<Divider sx={{marginTop: '10px', marginBottom: '10px', alignSelf: 'center'}}/>
|
||||||
<CommentsList comments={blacklistItem?.comments}/>
|
<DialogContent>
|
||||||
</DialogContent>
|
<NicknameList nicknames={blacklistItem?.nicknames}/>
|
||||||
</Dialog>
|
<CommentsList comments={blacklistItem?.comments}/>
|
||||||
)
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
onClose={() => handleClose()}
|
||||||
|
>
|
||||||
|
<DialogContent>
|
||||||
|
Error: No item
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import {BlacklistItem} from "~/classes/blacklistItem";
|
import {BlacklistItem} from "~/classes/blacklistItem";
|
||||||
import {Button, CircularProgress} from "@mui/material";
|
import {Button, CircularProgress} from "@mui/material";
|
||||||
|
import useWindowDimensions from "~/hooks/windowDimensions";
|
||||||
|
import trimLink from "~/functions/trimLink";
|
||||||
|
|
||||||
export default function ItemList({ isFetching, blacklistItems, showDialog }: { isFetching: boolean, blacklistItems: BlacklistItem[], showDialog: Function }) {
|
export default function ItemList({ isFetching, blacklistItems, showDialog }: { isFetching: boolean, blacklistItems: BlacklistItem[], showDialog: Function }) {
|
||||||
if (isFetching){
|
if (isFetching){
|
||||||
|
|
@ -10,11 +12,12 @@ export default function ItemList({ isFetching, blacklistItems, showDialog }: { i
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if (blacklistItems.length > 0){
|
if (blacklistItems.length > 0){
|
||||||
|
const { width } = useWindowDimensions();
|
||||||
return (
|
return (
|
||||||
<div className="list-container">
|
<div className="list-container">
|
||||||
<div className="item-list">
|
<div className="item-list">
|
||||||
{blacklistItems.map((item) => {
|
{blacklistItems.map((item) => {
|
||||||
return <Button onClick={() => showDialog(item)} variant="text">{item.link}</Button>
|
return <Button onClick={() => showDialog(item)} variant="text">{width < 570 ? trimLink(item.link) : item.link}</Button>
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import type {BlacklistItem} from "~/classes/blacklistItem";
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
|
@ -41,8 +40,16 @@ export default function ReportDialog({ open, handleClose }: { open: boolean, han
|
||||||
|
|
||||||
const handleSend = async () => {
|
const handleSend = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
|
let cleanLink = link.trim().toLowerCase();
|
||||||
|
|
||||||
|
if (cleanLink.endsWith('/')) {
|
||||||
|
cleanLink = cleanLink.slice(0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
setLink(cleanLink);
|
||||||
let blacklistReport = new BlacklistReport(
|
let blacklistReport = new BlacklistReport(
|
||||||
link,
|
cleanLink,
|
||||||
nickname,
|
nickname,
|
||||||
comment,
|
comment,
|
||||||
afk,
|
afk,
|
||||||
|
|
@ -52,8 +59,9 @@ export default function ReportDialog({ open, handleClose }: { open: boolean, han
|
||||||
useless,
|
useless,
|
||||||
smurf
|
smurf
|
||||||
);
|
);
|
||||||
|
|
||||||
await sendReport(blacklistReport).then((result: boolean) => {
|
await sendReport(blacklistReport).then((result: boolean) => {
|
||||||
setLoading(true);
|
setLoading(false);
|
||||||
clearValues();
|
clearValues();
|
||||||
handleClose();
|
handleClose();
|
||||||
});
|
});
|
||||||
|
|
@ -138,7 +146,7 @@ export default function ReportDialog({ open, handleClose }: { open: boolean, han
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div style={{width: '100%', display: 'flex', justifyContent: 'space-around'}}>
|
<div style={{width: '100%', display: 'flex', justifyContent: 'space-around'}}>
|
||||||
<Button onClick={() => handleSend()} variant="contained">Send</Button>
|
<Button loading={loading} onClick={() => handleSend()} variant="contained">Send</Button>
|
||||||
<Button onClick={() => handleClose()} variant="outlined">Cancel</Button>
|
<Button onClick={() => handleClose()} variant="outlined">Cancel</Button>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
export default function trimLink(link: string){
|
||||||
|
if (link.includes('/id')){
|
||||||
|
return link.split('/id')[1];
|
||||||
|
} else if (link.includes('/profiles')){
|
||||||
|
return link.split('/profiles')[1];
|
||||||
|
} else {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
|
export default function useWindowDimensions() {
|
||||||
|
// На сервере инициализируем значениями по умолчанию (0 или null)
|
||||||
|
const [dimensions, setDimensions] = useState({
|
||||||
|
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
||||||
|
height: typeof window !== 'undefined' ? window.innerHeight : 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Этот код гарантированно выполнится ТОЛЬКО в браузере
|
||||||
|
function handleResize() {
|
||||||
|
setDimensions({
|
||||||
|
width: window.innerWidth,
|
||||||
|
height: window.innerHeight,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Устанавливаем точные размеры сразу при монтировании
|
||||||
|
handleResize();
|
||||||
|
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
return () => window.removeEventListener('resize', handleResize);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue