generated from replugged-org/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d109be1
commit 3700285
Showing
6 changed files
with
239 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,65 @@ | ||
import { webpack, common, components } from "replugged"; | ||
import { useAuthorizationStore } from "../../lib/stores/AuthorizationStore"; | ||
import { authorizationStore } from "../../lib/stores/AuthorizationStore"; | ||
import { useCurrentUserDecorationsStore } from "../../lib/stores/CurrentUserDecorationsStore"; | ||
import { cl } from ".."; | ||
import { openChangeDecorationModal } from "../modals/ChangeDecorationModal"; | ||
|
||
const { React } = common | ||
const { Flex, Button } = components | ||
const { React } = common; | ||
const { Flex, Button } = components; | ||
let CustomizationSection; | ||
|
||
|
||
interface DecorSectionProps { | ||
hideTitle?: boolean; | ||
hideDivider?: boolean; | ||
noMargin?: boolean; | ||
} | ||
|
||
|
||
export default function DecorSection({ hideTitle = false, hideDivider = false, noMargin = false }: DecorSectionProps) { | ||
export default function DecorSection({ | ||
hideTitle = false, | ||
hideDivider = false, | ||
noMargin = false, | ||
}: DecorSectionProps) { | ||
CustomizationSection ??= webpack.getBySource(".customizationSectionBackground"); | ||
const authorization = useAuthorizationStore(); | ||
const { selectedDecoration, select: selectDecoration, fetch: fetchDecorations } = useCurrentUserDecorationsStore(); | ||
|
||
const { | ||
selectedDecoration, | ||
select: selectDecoration, | ||
fetch: fetchDecorations, | ||
} = useCurrentUserDecorationsStore(); | ||
|
||
React.useEffect(() => { | ||
if (authorization.isAuthorized()) fetchDecorations(); | ||
}, [authorization.token]); | ||
if (authorizationStore.isAuthorized()) fetchDecorations(); | ||
}, [authorizationStore.token]); | ||
|
||
return <CustomizationSection | ||
title={!hideTitle && "Decor"} | ||
hasBackground={true} | ||
hideDivider={hideDivider} | ||
className={noMargin && cl("section-remove-margin")} | ||
> | ||
<Flex> | ||
<Button | ||
onClick={() => { | ||
if (!authorization.isAuthorized()) { | ||
authorization.authorize().then(openChangeDecorationModal).catch(() => { }); | ||
} else openChangeDecorationModal(); | ||
// openChangeDecorationModal(); | ||
}} | ||
size={Button.Sizes.SMALL} | ||
> | ||
Change Decoration | ||
</Button> | ||
{selectedDecoration && authorization.isAuthorized() && <Button | ||
onClick={() => selectDecoration(null)} | ||
color={Button.Colors.PRIMARY} | ||
size={Button.Sizes.SMALL} | ||
look={Button.Looks.LINK} | ||
> | ||
Remove Decoration | ||
</Button>} | ||
</Flex> | ||
</CustomizationSection> | ||
return ( | ||
<CustomizationSection | ||
title={!hideTitle && "Decor"} | ||
hasBackground={true} | ||
hideDivider={hideDivider} | ||
className={noMargin && cl("section-remove-margin")}> | ||
<Flex> | ||
<Button | ||
onClick={() => { | ||
if (!authorizationStore.isAuthorized()) { | ||
authorizationStore | ||
.authorize() | ||
.then(openChangeDecorationModal) | ||
.catch(() => {}); | ||
} else openChangeDecorationModal(); | ||
// openChangeDecorationModal(); | ||
}} | ||
size={Button.Sizes.SMALL}> | ||
Change Decoration | ||
</Button> | ||
{selectedDecoration && authorizationStore.isAuthorized() && ( | ||
<Button | ||
onClick={() => selectDecoration(null)} | ||
color={Button.Colors.PRIMARY} | ||
size={Button.Sizes.SMALL} | ||
look={Button.Looks.LINK}> | ||
Remove Decoration | ||
</Button> | ||
)} | ||
</Flex> | ||
</CustomizationSection> | ||
); | ||
} |
Oops, something went wrong.