feat : progress bar config for space is dynamic from api

This commit is contained in:
alij
2024-06-24 00:53:08 +04:30
parent ac023a626a
commit 3c1df40448
5 changed files with 28 additions and 9 deletions

View File

@@ -19,21 +19,28 @@ const ProgressSpace = ({ startSpace, endSpace }: ProgressSpaceProps) => {
<div className="w-full rounded-full h-2 md:h-2.5 bg-gray-700"> <div className="w-full rounded-full h-2 md:h-2.5 bg-gray-700">
<motion.div <motion.div
className="bg-secondTheme h-2 md:h-2.5 rounded-full" className="bg-secondTheme h-2 md:h-2.5 rounded-full"
animate={{ width: `${startSpacePercentage}%` }}
initial={{ width: 0 }} initial={{ width: 0 }}
animate={{
width: `${
endSpace === "unlimited" ? 100 : startSpacePercentage
}%`,
}}
transition={{ type: "tween", duration: 1 }} transition={{ type: "tween", duration: 1 }}
style={{ transformOrigin: "right" }} style={{ transformOrigin: "right" }}
></motion.div> ></motion.div>
</div> </div>
<div className="flex flex-row-reverse gap-1"> <div className="flex flex-row-reverse gap-1">
<span> {endSpace}</span> <span> {endSpace === "unlimited" ? "نامحدود" : endSpace}</span>
<span>GB</span> {endSpace !== "unlimited" && <span>GB</span>}
</div> </div>
</div> </div>
<div className="w-full h-full mt-1 p-2 text-center text-xs md:text-base"> <div className="w-full h-full mt-1 p-2 text-center text-xs md:text-base">
<p> <p>
{" "} {" "}
حجم باقیمانده کانفیگ شما از {endSpace} گیگ <span className="mx-1 border-b border-secondTheme">{remaining}</span>گیگ میباشد{" "} حجم باقیمانده کانفیگ شما از{" "}
{endSpace === "unlimited" ? "نامحدود" : endSpace} گیگ{" "}
<span className="mx-1 border-b border-secondTheme">{remaining}</span>
گیگ میباشد{" "}
</p> </p>
</div> </div>
</> </>

View File

@@ -64,6 +64,8 @@ const ProductConfigList = ({
isDisabled={false} isDisabled={false}
isShowTraffic={item.show_traffic} isShowTraffic={item.show_traffic}
textCopy={item.url} textCopy={item.url}
maxTraffic={item.max_traffic}
traffic={item.traffic}
/> />
</Fragment> </Fragment>
); );

View File

@@ -14,6 +14,8 @@ const ConfigItem = ({
isDisabled, isDisabled,
isShowTraffic, isShowTraffic,
textCopy, textCopy,
maxTraffic,
traffic,
}: ConfigItemProps) => { }: ConfigItemProps) => {
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [isOpenDropDown, setIsOpenDropDown] = useState(false); const [isOpenDropDown, setIsOpenDropDown] = useState(false);
@@ -40,6 +42,8 @@ const ConfigItem = ({
nameConfig={configName} nameConfig={configName}
isShowTraffic={isShowTraffic} isShowTraffic={isShowTraffic}
textCopy={textCopy} textCopy={textCopy}
maxTraffic={maxTraffic}
traffic={traffic}
/> />
<div className="relative w-full h-full rounded-md"> <div className="relative w-full h-full rounded-md">
{isDisabled && ( {isDisabled && (
@@ -91,7 +95,7 @@ const ConfigItem = ({
حجم حجم
</Button> </Button>
<DropdownItem widthTailwind="w-[20rem] left-0"> <DropdownItem widthTailwind="w-[20rem] left-0">
<ProgressSpace startSpace={100} endSpace={200} /> <ProgressSpace startSpace={traffic} endSpace={maxTraffic} />
</DropdownItem> </DropdownItem>
</Dropdown> </Dropdown>
)} )}

View File

@@ -14,7 +14,9 @@ const ModalConfigDetails = ({
dateBuy, dateBuy,
nameConfig, nameConfig,
isShowTraffic, isShowTraffic,
textCopy textCopy,
maxTraffic,
traffic
}: { }: {
isOpen: boolean; isOpen: boolean;
setIsOpen: Dispatch<SetStateAction<boolean>>; setIsOpen: Dispatch<SetStateAction<boolean>>;
@@ -23,6 +25,8 @@ const ModalConfigDetails = ({
nameConfig: string; nameConfig: string;
isShowTraffic: boolean; isShowTraffic: boolean;
textCopy: string; textCopy: string;
maxTraffic: number | "unlimited";
traffic: number;
}) => { }) => {
const navigate = useNavigate() const navigate = useNavigate()
const copyToClipboard = async (textToCopy: string) => { const copyToClipboard = async (textToCopy: string) => {
@@ -64,9 +68,9 @@ const ModalConfigDetails = ({
</> </>
)} )}
</div> </div>
{!isDisabled || isShowTraffic && ( {!isDisabled && isShowTraffic && (
<div className="w-full h-full"> <div className="w-full h-full">
<ProgressSpace startSpace={100} endSpace={200} /> <ProgressSpace startSpace={traffic} endSpace={maxTraffic} />
</div> </div>
)} )}
</div> </div>

View File

@@ -128,6 +128,8 @@ export interface ConfigItemProps {
isDisabled: boolean; isDisabled: boolean;
isShowTraffic: boolean; isShowTraffic: boolean;
textCopy: string; textCopy: string;
maxTraffic: number | "unlimited";
traffic: number;
} }
// نوع Item برای آیتم‌های داخل Dropdown // نوع Item برای آیتم‌های داخل Dropdown
@@ -145,7 +147,7 @@ export interface DropdownProps {
export interface ProgressSpaceProps { export interface ProgressSpaceProps {
startSpace: number; startSpace: number;
endSpace: number | "ultimate"; endSpace: number | "unlimited";
} }
export interface LoginFormValues { export interface LoginFormValues {