Skip to content

Commit

Permalink
added disable prop to slide button and modules refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Andcool-Systems committed Aug 8, 2024
1 parent 4e77f0a commit 4fe2e23
Show file tree
Hide file tree
Showing 39 changed files with 262 additions and 248 deletions.
6 changes: 3 additions & 3 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import { Cookies, useCookies } from "next-client-cookies";
import useCookie from "@/app/modules/useCookie.module";
import useCookie from "@/app/modules/utils/useCookie.module";
import { useEffect, useRef } from "react";
import { redirect, useRouter } from "next/navigation";
import Header, { Query } from "@/app/modules/header.module";
import { authApi } from "@/app/modules/api.module";
import Header, { Query } from "@/app/modules/components/header.module";
import { authApi } from "@/app/modules/utils/api.module";

const Admin = () => {
const logged = useCookie('sessionId');
Expand Down
2 changes: 1 addition & 1 deletion src/app/contacts/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "next/link";
import Header from "@/app/modules/header.module";
import Header from "@/app/modules/components/header.module";
import style from '@/app/styles/contacts/contacts.module.css';
import { Metadata } from "next";

Expand Down
12 changes: 6 additions & 6 deletions src/app/me/notifications/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import React, { useEffect, useRef, useState } from 'react';
import { redirect, } from "next/navigation";
import Style from "@/app/styles/me/notifications.module.css";
import Header from "@/app/modules/header.module";
import useCookie from '@/app/modules/useCookie.module';
import { Me } from '@/app/modules/me.module';
import { authApi } from '@/app/modules/api.module';
import { formatDate } from '@/app/modules/card.module';
import { Paginator } from '@/app/modules/paginator.module';
import Header from "@/app/modules/components/header.module";
import useCookie from '@/app/modules/utils/useCookie.module';
import { Me } from '@/app/modules/components/me.module';
import { authApi } from '@/app/modules/utils/api.module';
import { formatDate } from '@/app/modules/components/card.module';
import { Paginator } from '@/app/modules/components/paginator.module';
import style_sidebar from "@/app/styles/me/sidebar.module.css";
import Image from "next/image";
import { Cookies, useCookies } from 'next-client-cookies';
Expand Down
14 changes: 7 additions & 7 deletions src/app/me/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

import React from 'react';
import { useEffect, useState, useRef } from 'react';
import { authApi } from "@/app/modules/api.module";
import { authApi } from "@/app/modules/utils/api.module";
import { useRouter } from "next/navigation";
import styles from "@/app/styles/me/me.module.css";
import { Tooltip } from '@/app/modules/tooltip';
import Header from "@/app/modules/header.module";
import useCookie from '@/app/modules/useCookie.module';
import { Tooltip } from '@/app/modules/components/tooltip';
import Header from "@/app/modules/components/header.module";
import useCookie from '@/app/modules/utils/useCookie.module';
import { Cookies, useCookies } from 'next-client-cookies';
import { Bandage, Role } from '@/app/interfaces';
import { SkinViewer } from 'skinview3d';
import { Card, generateSkin } from '@/app/modules/card.module';
import { Me } from '@/app/modules/me.module';
import { Card, generateSkin } from '@/app/modules/components/card.module';
import { Me } from '@/app/modules/components/me.module';
import Link from 'next/link';
import axios from 'axios';
import AdaptiveGrid from '@/app/modules/adaptiveGrid.module';
import AdaptiveGrid from '@/app/modules/components/adaptiveGrid.module';
import style_workshop from "@/app/styles/workshop/page.module.css";
import NextImage from 'next/image';

Expand Down
71 changes: 40 additions & 31 deletions src/app/me/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
import React, { ChangeEvent, useEffect } from 'react';
import { useState } from 'react';
import { useQuery } from "@tanstack/react-query";
import { authApi } from "@/app/modules/api.module";
import { authApi } from "@/app/modules/utils/api.module";
import { redirect } from "next/navigation";
import Style from "@/app/styles/me/connections.module.css";
import Style_themes from "@/app/styles/me/themes.module.css";
import Header from "@/app/modules/header.module";
import useCookie from '@/app/modules/useCookie.module';
import Header from "@/app/modules/components/header.module";
import useCookie from '@/app/modules/utils/useCookie.module';
import Image from 'next/image';
import { Me } from '@/app/modules/me.module';
import { Me } from '@/app/modules/components/me.module';
import { Fira_Code } from "next/font/google";
import { SlideButton } from '@/app/modules/nick_search.module';
import { formatDate } from '@/app/modules/card.module';
import { SlideButton } from '@/app/modules/components/nick_search.module';
import { formatDate } from '@/app/modules/components/card.module';
import { getTheme } from '@/app/modules/providers.module';
import { useCookies } from 'next-client-cookies';
const fira = Fira_Code({ subsets: ["latin"] });

interface SettingsResponse {
statusCode: number,
public_profile: boolean,
can_be_public: boolean,
connections: {
discord: {
user_id: number,
Expand Down Expand Up @@ -101,7 +102,7 @@ const UserSettings = ({ data }: { data: SettingsResponse }) => {
return (
<div className={Style.container}>
<h3><Image src="/static/icons/user.svg" alt="" width={26} height={26} style={{ marginRight: ".3rem", borderRadius: 0 }} />Настройки аккаунта</h3>
<SlideButton label='Публичный профиль' value={value} onChange={change} strict={true} />
<SlideButton label='Публичный профиль' value={data.can_be_public ? value : false} onChange={change} strict={true} disabled={!data.can_be_public} />
</div>
);
}
Expand All @@ -110,6 +111,32 @@ const Connections = ({ data, refetch }: { data: SettingsResponse, refetch(): voi
const [valid, setValid] = useState<boolean>(data.connections.minecraft?.valid);
const [autoload, setAutoload] = useState<boolean>(data.connections?.minecraft?.autoload);

const refresh = () => {
const load_icon = document.getElementById('refresh');
load_icon.style.animation = `${Style.loading} infinite 1s linear`;
authApi.post("user/me/connections/minecraft/cache/purge").then((response) => {
if (response.status === 200) {
refetch();
return;
}
alert(response.data.message);
}).finally(() => {
load_icon.style.animation = null;
})
}

const disconnect = () => {
const confirmed = confirm("Отвязать учётную запись Minecraft? Вы сможете в любое время привязать ее обратно.");
if (confirmed) {
authApi.delete('user/me/connections/minecraft').then((response) => {
if (response.status === 200) {
refetch();
return;
}
})
}
}

return (
<div className={Style.container}>
<h3><Image src="/static/icons/discord.svg" alt="" width={32} height={32} style={{ marginRight: ".4rem", borderRadius: 0 }} />Discord аккаунт</h3>
Expand Down Expand Up @@ -162,31 +189,13 @@ const Connections = ({ data, refetch }: { data: SettingsResponse, refetch(): voi
</div>
<div className={Style.checkboxes}>
<span>Последний раз кэшировано {formatDate(new Date(data.connections?.minecraft?.last_cached))}</span>
<button className={Style.unlink} onClick={() => {
const load_icon = document.getElementById('refresh');
load_icon.style.animation = `${Style.loading} infinite 1s linear`;
authApi.post("user/me/connections/minecraft/cache/purge").then((response) => {
if (response.status === 200) {
refetch();
return;
}
alert(response.data.message);
}).finally(() => {
load_icon.style.animation = null;
})
}}><img alt="" src="/static/icons/refresh.svg" style={{ width: "1.5rem" }} id="refresh" />Обновить кэш</button>
<button className={Style.unlink} onClick={() => refresh()}>
<img alt="" src="/static/icons/refresh.svg" style={{ width: "1.5rem" }} id="refresh" />Обновить кэш
</button>

<button className={Style.unlink} onClick={() => {
const confirmed = confirm("Отвязать учётную запись Minecraft? Вы сможете в любое время привязать ее обратно.");
if (confirmed) {
authApi.delete('user/me/connections/minecraft').then((response) => {
if (response.status === 200) {
refetch();
return;
}
})
}
}}><img alt="" src="/static/icons/plus.svg" style={{ width: "1.8rem", transform: "rotate(45deg)" }} />Отвязать</button>
<button className={Style.unlink} onClick={() => disconnect()}>
<img alt="" src="/static/icons/plus.svg" style={{ width: "1.8rem", transform: "rotate(45deg)" }} />Отвязать
</button>
</div>
</> : <>
<p style={{ margin: 0 }}>Привяжите свою учётную запись Minecraft к учетной записи PPLBandage для управления кешем скинов и настройками видимости
Expand Down
12 changes: 6 additions & 6 deletions src/app/me/stars/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import React from 'react';
import { useEffect, useState, useRef } from 'react';
import { authApi } from "@/app/modules/api.module";
import { authApi } from "@/app/modules/utils/api.module";
import style_sidebar from "@/app/styles/me/sidebar.module.css";
import Header from "@/app/modules/header.module";
import useCookie from '@/app/modules/useCookie.module';
import Header from "@/app/modules/components/header.module";
import useCookie from '@/app/modules/utils/useCookie.module';
import { Cookies, useCookies } from 'next-client-cookies';
import styles_me from "@/app/styles/me/me.module.css";
import Image from 'next/image';
import { Bandage } from '@/app/interfaces';
import { SkinViewer } from 'skinview3d';
import { Card, generateSkin } from '@/app/modules/card.module';
import { Me } from '@/app/modules/me.module';
import { Card, generateSkin } from '@/app/modules/components/card.module';
import { Me } from '@/app/modules/components/me.module';
import { redirect } from 'next/navigation'
import AdaptiveGrid from '@/app/modules/adaptiveGrid.module';
import AdaptiveGrid from '@/app/modules/components/adaptiveGrid.module';

const Main = () => {
const cookies = useRef<Cookies>(useCookies());
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { authApi } from "./api.module";
import { authApi } from "@/app/modules/utils/api.module";
import { Bandage, Category } from "@/app/interfaces";
import Style from "@/app/styles/workshop/page.module.css";
import NextImage from 'next/image';
import { fillPepe } from "@/app/workshop/[id]/bandage_engine.module";
import { getCookie } from "cookies-next";
import Link from "next/link";
import { CSSProperties, useEffect, useState } from "react";
import asyncImage from "./asyncImage.module";
import asyncImage from "@/app/modules/components/asyncImage.module";

const b64Prefix = "data:image/png;base64,";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react"
import { Category } from "@/app/interfaces"
import { CategoryEl } from "@/app/modules/card.module";
import { CategoryEl } from "@/app/modules/components/card.module";
import style from "@/app/styles/category_selector.module.css";
import NextImage from 'next/image';
import style_workshop from "@/app/styles/workshop/page.module.css";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use client";

import { authApi } from "./api.module";
import { authApi } from "@/app/modules/utils/api.module";
import { useEffect, useState } from "react";
import Styles from "@/app/styles/header.module.css";
import { CSSTransition } from 'react-transition-group';
import { deleteCookie } from 'cookies-next';
import Link from 'next/link';
import Image from 'next/image';
import { useQuery } from "@tanstack/react-query";
import useCookie from "./useCookie.module";
import useCookie from "@/app/modules/utils/useCookie.module";

export interface Query {
username: string;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useQuery } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { authApi } from "./api.module";
import { authApi } from "../utils/api.module";
import { Query } from "./header.module";
import style_sidebar from "@/app/styles/me/sidebar.module.css";
import Image from 'next/image';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { timeStamp } from "./time.module";
import { timeStamp } from "../utils/time.module";
import Footer from "./footer.module";
import { useCookies } from 'next-client-cookies';
import Menu from "./theme_select.module";
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ interface SlideButtonProps {
value?: boolean;
label?: string;
defaultValue?: boolean;
strict?: boolean
strict?: boolean,
disabled?: boolean
}

export const SlideButton = ({ onChange, value, label, defaultValue, strict }: SlideButtonProps) => {
export const SlideButton = ({ onChange, value, label, defaultValue, strict, disabled }: SlideButtonProps) => {
const [active, setActive] = useState<boolean>(value || defaultValue || false);
const isInitialMount = useRef<boolean>(true);
console.log(disabled)

useEffect(() => {
setActive(value || defaultValue || false);
Expand All @@ -128,10 +130,11 @@ export const SlideButton = ({ onChange, value, label, defaultValue, strict }: Sl
}
}, [active]);

const color = disabled ? 'var(--category-color)' : (active ? undefined : 'rgb(77 83 99)');
return (
<div className={StyleBtn.container}>
<div className={StyleBtn.main} onClick={() => setActive(prev => !prev)}>
<div className={StyleBtn.child} style={active ? { left: "1.3rem" } : { left: "0", backgroundColor: "rgb(77 83 99)" }} />
<div className={StyleBtn.main} onClick={() => setActive(prev => !disabled ? !prev : prev)} style={{ cursor: disabled ? 'auto' : 'pointer' }}>
<div className={StyleBtn.child} style={active ? { left: "1.3rem", backgroundColor: color } : { left: "0", backgroundColor: color }} />
</div>
{label && <label className={StyleBtn.label}>{label}</label>}
</div>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import Footer from './modules/footer.module';
import Header from './modules/header.module';
import NotFoundElement from './modules/nf.module';
import Footer from './modules/components/footer.module';
import Header from './modules/components/header.module';
import NotFoundElement from './modules/components/nf.module';

export default function NotFound() {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/app/root_client.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import Image from "next/image";
import Header from "./modules/header.module";
import Header from "./modules/components/header.module";
import React, { useState } from "react";
import Style from "./styles/root/page.module.css";
import Link from "next/link";
import { CustomLink } from "./modules/search.module";
import { CustomLink } from "./modules/components/search.module";


const HomeClient = ({ pong }: { pong: number }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/tos/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Footer from "@/app/modules/footer.module";
import Header from "@/app/modules/header.module";
import Footer from "@/app/modules/components/footer.module";
import Header from "@/app/modules/components/header.module";
import style from '@/app/styles/tutorials/common.module.css';

const Main = () => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/tutorials/bandage/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use client";

import Footer from "@/app/modules/footer.module";
import Header from "@/app/modules/header.module";
import Footer from "@/app/modules/components/footer.module";
import Header from "@/app/modules/components/header.module";
import React from "react";
import style from '@/app/styles/tutorials/common.module.css';
import ASide from "@/app/tutorials/header.module";
import { CustomLink } from "@/app/modules/search.module";
import InfoCard from "@/app/modules/info.module";
import { CustomLink } from "@/app/modules/components/search.module";
import InfoCard from "@/app/modules/components/info.module";
import styleLink from '@/app/styles/tutorials/common.module.css';
import NextImage from "next/image";

Expand Down
8 changes: 4 additions & 4 deletions src/app/tutorials/colorable/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use client";

import Footer from "@/app/modules/footer.module";
import Header from "@/app/modules/header.module";
import Footer from "@/app/modules/components/footer.module";
import Header from "@/app/modules/components/header.module";
import React from "react";
import style from '@/app/styles/tutorials/common.module.css';
import ASide from "@/app/tutorials/header.module";
import InfoCard from "@/app/modules/info.module";
import InfoCard from "@/app/modules/components/info.module";
import NextImage from 'next/image';
import { CategoryEl } from "@/app/modules/card.module";
import { CategoryEl } from "@/app/modules/components/card.module";

export default function Home() {
return (
Expand Down
12 changes: 6 additions & 6 deletions src/app/tutorials/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"use client";

import Footer from "@/app/modules/footer.module";
import Header from "@/app/modules/header.module";
import Footer from "@/app/modules/components/footer.module";
import Header from "@/app/modules/components/header.module";
import React, { useEffect, useState } from "react";
import style from '@/app/styles/tutorials/common.module.css';
import ASide from "./header.module";
import InfoCard from "@/app/modules/info.module";
import InfoCard from "@/app/modules/components/info.module";
import NextImage from "next/image";
import { CategoryEl } from "@/app/modules/card.module";
import { CustomLink } from "@/app/modules/search.module";
import { CategoryEl } from "@/app/modules/components/card.module";
import { CustomLink } from "@/app/modules/components/search.module";
import styles from "@/app/styles/me/me.module.css";
import { Tooltip } from "@/app/modules/tooltip";
import { Tooltip } from "@/app/modules/components/tooltip";
import axios from "axios";
import { Role } from "@/app/interfaces";
import style_workshop from "@/app/styles/workshop/page.module.css";
Expand Down
Loading

0 comments on commit 4fe2e23

Please sign in to comment.