From 22010bb3ae896e0675f7a7a6e8497f60b752caaf Mon Sep 17 00:00:00 2001 From: bflatastic Date: Thu, 23 May 2024 23:56:36 +0700 Subject: [PATCH] beta keys list filter show only unredeemed checkbox --- .../components/common/Checkbox/Checkbox.scss | 36 +++++++++---- .../components/common/Checkbox/Checkbox.tsx | 53 ++++++++++++++----- .../src/components/svg/Check/Check.tsx | 32 ++++++----- .../view/pages/beta_key/BetaKeysListPage.tsx | 41 +++++++++----- 4 files changed, 112 insertions(+), 50 deletions(-) diff --git a/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.scss b/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.scss index a2980e3fbb..39b426b633 100644 --- a/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.scss +++ b/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.scss @@ -1,43 +1,57 @@ @import "scss/colours.scss"; .fy-checkbox-frame { - margin-bottom: .5rem; + margin-bottom: 0.5rem; white-space: nowrap; cursor: pointer; label { - margin-left: .5rem; - cursor: pointer; + margin-left: 0.6rem; + cursor: pointer; } } -.fy-checkbox-primary-unchecked, .fy-checkbox-primary-checked { +.fy-checkbox-primary-unchecked, +.fy-checkbox-primary-checked { .fy-checkbox { background-color: $primary; } - &:hover { + &:hover { .fy-checkbox { background-color: lighten($primary, 5%); } } } -.fy-checkbox-secondary-unchecked, .fy-checkbox-secondary-checked { +.fy-checkbox-secondary-unchecked, +.fy-checkbox-secondary-checked { .fy-checkbox { background-color: $secondary; } - &:hover { + &:hover { .fy-checkbox { background-color: $secondary-light; } } } +.fy-checkbox-secondary-checked { + .fy-checkbox { + background-color: $primary; + } + &:hover { + .fy-checkbox { + background-color: lighten($primary, 5%); + } + } +} + .fy-checkbox { - border-radius: .5rem; + border-radius: 0.35rem; display: inline-block; vertical-align: middle; - height: 2rem; - width: 2rem; + height: 1.5rem; + width: 1.5rem; stroke: white; -} \ No newline at end of file + transition: 0.2s; +} diff --git a/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.tsx b/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.tsx index 7611848b7e..65ab69e22f 100644 --- a/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.tsx +++ b/packages/fakeyou.com/src/components/common/Checkbox/Checkbox.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; import { Check } from "components/svg"; import { useId } from "hooks"; import makeClass from "resources/makeClass"; @@ -10,18 +10,45 @@ interface Props { label?: string; name?: string; onChange?: any; - variant?: "primary" | "secondary"; + variant?: "primary" | "secondary"; } -export default function Checkbox({ checked, className = "", label = "", name = "", onChange, variant = "secondary" }: Props) { - const onClick = ({ target }: any) => onChange({ target: { checked: !checked, name, type: 'checkbox' } }); +export default function Checkbox({ + checked, + className = "", + label = "", + name = "", + onChange, + variant = "secondary", +}: Props) { + const onClick = ({ target }: any) => + onChange({ target: { checked: !checked, name, type: "checkbox" } }); const id = "checkbox-" + useId(); - return
- - - - { label && } -
-}; \ No newline at end of file + return ( +
+ + + + {label && ( + + )} +
+ ); +} diff --git a/packages/fakeyou.com/src/components/svg/Check/Check.tsx b/packages/fakeyou.com/src/components/svg/Check/Check.tsx index 0c4a988a4d..12a6d94380 100644 --- a/packages/fakeyou.com/src/components/svg/Check/Check.tsx +++ b/packages/fakeyou.com/src/components/svg/Check/Check.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; import { a, useSpring } from "@react-spring/web"; interface Props { @@ -7,17 +7,21 @@ interface Props { export default function Check({ checked }: Props) { const style = useSpring({ - config: { tension: 280, friction: 60 }, - strokeDasharray: checked ? '28, 0' : '0,28' + config: { tension: 280, friction: 20 }, + strokeDasharray: checked ? "28, 0" : "0,28", }); - return ; -}; \ No newline at end of file + return ( + + ); +} diff --git a/packages/fakeyou.com/src/v2/view/pages/beta_key/BetaKeysListPage.tsx b/packages/fakeyou.com/src/v2/view/pages/beta_key/BetaKeysListPage.tsx index 3f9f51e13b..888970a0c5 100644 --- a/packages/fakeyou.com/src/v2/view/pages/beta_key/BetaKeysListPage.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/beta_key/BetaKeysListPage.tsx @@ -10,6 +10,7 @@ import { } from "@tanstack/react-table"; import { Button, + Checkbox, Container, Pagination, Panel, @@ -34,6 +35,7 @@ export default function BetaKeysListPage() { const urlQueries = new URLSearchParams(search); const [list, listSet] = useState([]); const [username, usernameSet] = useState(""); + const [onlyUnredeemed, onlyUnredeemedSet] = useState("false"); const keysList = useListContent({ addQueries: { @@ -41,6 +43,7 @@ export default function BetaKeysListPage() { ...(username.trim() ? prepFilter(username, "maybe_referrer_username") : {}), + ...prepFilter(onlyUnredeemed, "only_list_remaining"), }, addSetters: { usernameSet }, debug: "ListBetaKeys", @@ -170,25 +173,39 @@ export default function BetaKeysListPage() { usernameSet(e.target.value); }; + const handleShowOnlyUnredeemed = (e: React.ChangeEvent) => { + onlyUnredeemedSet(e.target.checked ? "true" : "false"); + keysList.reFetch(); + }; + return (
-
- { - if (event.key === "Enter") { - keysList.reFetch(); - } - }} +
+
+ { + if (event.key === "Enter") { + keysList.reFetch(); + } + }} + /> +
+ + -