Skip to content

Commit

Permalink
Apply link
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamXZE committed Mar 14, 2023
1 parent d3bc413 commit f815f8b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { FunctionComponent, useState, useEffect } from 'react';
import { MenuType } from '../../../shared/nui/menu';
import { FunctionComponent, useEffect, useState } from 'react';

import { FfsComponent, Outfit, Prop } from '../../../shared/cloth';
import { useNuiEvent } from '../../hook/nui';
import { NuiEvent } from '../../../shared/event';
import { fetchNui } from '../../fetch';
import { MenuType } from '../../../shared/nui/menu';
import { isOk, Result } from '../../../shared/result';
import { fetchNui } from '../../fetch';
import { useNuiEvent } from '../../hook/nui';
import {
MainMenu,
Menu,
MenuContent,
MenuItemSubMenuLink,
MenuItemButton,
MenuItemCheckbox,
MenuItemSelect,
MenuItemSelectOption,
MenuItemButton,
MenuItemSubMenuLink,
MenuTitle,
SubMenu,
} from '../Styleguide/Menu';
Expand Down Expand Up @@ -50,7 +51,7 @@ type FightForStyleShowRoomComponent = {
}[];
};
can_craft: boolean;
}
};
};

export interface NuiFFSSubMenuMethodMap {
Expand All @@ -74,18 +75,20 @@ export interface NuiFFSSubMenuMethodMap {
export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomComponent> = ({ data }) => {
const banner = 'https://nui-img/soz/menu_job_ffs';
const [currentDrawable, setCurrentDrawable] = useState<number>(0);
const [currentCraft, setcurrentCraft] = useState<{ drawables: object, props: object}>();
const [shouldCraft, setshouldCraft] = useState<{ drawables: object, props: object}>();
const [currentCraft, setcurrentCraft] = useState<{ drawables: object; props: object }>();
const [shouldCraft, setshouldCraft] = useState<{ drawables: object; props: object }>();
const [description, setDescription] = useState<string>();
const state = data.state;
const can_craft = data.can_craft;

useEffect(() => {
fetchNui<never, Result<{ drawables: object, props: object}, never>>(NuiEvent.FfsMenuCraftingPanel).then(result => {
if (isOk(result)) {
setcurrentCraft(result.ok);
fetchNui<never, Result<{ drawables: object; props: object }, never>>(NuiEvent.FfsMenuCraftingPanel).then(
result => {
if (isOk(result)) {
setcurrentCraft(result.ok);
}
}
});
);
}, [currentDrawable]);

useNuiEvent(
Expand All @@ -100,13 +103,9 @@ export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomC
}
);

useNuiEvent(
'ffs_skin_submenu',
'SetClotheDescription',
async (data: { description: string }) => {
setDescription(data.description)
}
);
useNuiEvent('ffs_skin_submenu', 'SetClotheDescription', async (data: { description: string }) => {
setDescription(data.description);
});

useNuiEvent('menu', 'Backspace', () => {
setCurrentDrawable(0);
Expand Down Expand Up @@ -186,7 +185,9 @@ export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomC
👕 Vêtements, chaussures, masques et accessoires
</MenuItemSubMenuLink>
<MenuItemSubMenuLink id={'player_style_props'}>🎩 Autres accessoires</MenuItemSubMenuLink>
<MenuItemSubMenuLink id={'crafting_menu'} disabled={!can_craft}>Selection et Confection des tenues</MenuItemSubMenuLink>
<MenuItemSubMenuLink id={'crafting_menu'} disabled={!can_craft}>
Selection et Confection des tenues
</MenuItemSubMenuLink>
</MenuContent>
</MainMenu>
<SubMenu id={'player_style_components'}>
Expand Down Expand Up @@ -215,13 +216,15 @@ export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomC
{Object.keys(currentCraft?.drawables || {}).map(componentIndex => (
<MenuItemCheckbox
checked={shouldCraft?.drawables?.[componentIndex] || false}
onChange={async (value) => {
onChange={async value => {
await fetchNui(NuiEvent.FfsShowRoomSelectToCraft, {
type: 'drawables',
index: componentIndex,
value: value
})
await fetchNui<never, Result<{ drawables: object, props: object}, never>>(NuiEvent.FfsMenuShouldCraftPanel).then(result => {
value: value,
});
await fetchNui<never, Result<{ drawables: object; props: object }, never>>(
NuiEvent.FfsMenuShouldCraftPanel
).then(result => {
if (isOk(result)) {
setshouldCraft(result.ok);
}
Expand All @@ -234,13 +237,15 @@ export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomC
{Object.keys(currentCraft?.props || {}).map(propIndex => (
<MenuItemCheckbox
checked={shouldCraft?.props?.[propIndex] || false}
onChange={async (value) => {
onChange={async value => {
await fetchNui(NuiEvent.FfsShowRoomSelectToCraft, {
type: 'props',
index: propIndex,
value: value
})
await fetchNui<never, Result<{ drawables: object, props: object}, never>>(NuiEvent.FfsMenuShouldCraftPanel).then(result => {
value: value,
});
await fetchNui<never, Result<{ drawables: object; props: object }, never>>(
NuiEvent.FfsMenuShouldCraftPanel
).then(result => {
if (isOk(result)) {
setshouldCraft(result.ok);
}
Expand All @@ -259,7 +264,9 @@ export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomC
onConfirm={async () => {
await fetchNui(NuiEvent.FfsMenuCraftOutfit);
}}
>Confectionner la tenue</MenuItemButton>
>
Confectionner la tenue
</MenuItemButton>
</MenuContent>
</SubMenu>

Expand Down Expand Up @@ -300,8 +307,10 @@ export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomC
await onComponentChange(componentIndex, 'texture', index);
}}
>
{Array(state.maxOptions.find(option => option.componentIndex === Number(componentIndex))
?.maxTextures || 0)
{Array(
state.maxOptions.find(option => option.componentIndex === Number(componentIndex))
?.maxTextures || 0
)
.fill(0)
.map((_, index) => (
<MenuItemSelectOption value={index} key={`${componentIndex}_texture_${index}`}>
Expand Down Expand Up @@ -349,8 +358,10 @@ export const FightForStyleShowRoomMenu: FunctionComponent<FightForStyleShowRoomC
await onPropChange(propIndex, 'texture', index);
}}
>
{Array(state.maxOptions.find(option => option.propIndex === Number(propIndex))
?.maxTextures || 0)
{Array(
state.maxOptions.find(option => option.propIndex === Number(propIndex))?.maxTextures ||
0
)
.fill(0)
.map((_, index) => (
<MenuItemSelectOption value={index} key={`${propIndex}_texture_${index}`}>
Expand Down
5 changes: 4 additions & 1 deletion resources/[soz]/soz-core/src/nui/components/Menu/MenuApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ const MenuRouter: FunctionComponent = () => {
<Route path={`/${MenuType.BennysOrderMenu}`} element={<BennysOrderMenu />} />
<Route path={`/${MenuType.Demo}/*`} element={<MenuDemo />} />
<Route path={`/${MenuType.FightForStyleJobMenu}/*`} element={<FightForStyleJobMenu data={menuData} />} />
<Route path={`/${MenuType.FightForStyleShowRoomMenu}/*`} element={<FightForStyleShowRoomMenu data={menuData} />} />
<Route
path={`/${MenuType.FightForStyleShowRoomMenu}/*`}
element={<FightForStyleShowRoomMenu data={menuData} />}
/>
<Route path={`/${MenuType.StonkJobMenu}/*`} element={<StonkJobMenu data={menuData} />} />
<Route path={`/${MenuType.FoodJobMenu}/*`} element={<FoodJobMenu data={menuData} />} />
<Route path={`/${MenuType.MaskShop}/*`} element={<MaskShopMenu catalog={menuData} />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export class FightForStylShowRoomProvider {
const player = this.qbcore.getPlayer(source);

let cost_mult = 0;
Object.keys(outfit['Components']).forEach(_ => {
Object.keys(outfit['Components']).forEach(() => {
cost_mult++;
});
Object.keys(outfit['Props']).forEach(_ => {
Object.keys(outfit['Props']).forEach(() => {
cost_mult++;
});

Expand Down

0 comments on commit f815f8b

Please sign in to comment.