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.
Merge pull request #4 from Tharki-God/works
Works
- Loading branch information
Showing
8 changed files
with
264 additions
and
245 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,4 +1,4 @@ | ||
import { settings } from "replugged" | ||
import { settings } from "replugged"; | ||
|
||
export const defaultSettings = {} | ||
export const authorizationToken = settings.init("decor.auth", defaultSettings) | ||
export const defaultSettings = {}; | ||
export const authorizationToken = await settings.init("decor.auth", defaultSettings); |
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,63 @@ | ||
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(); | ||
openChangeDecorationModal(); | ||
} 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.