Skip to content

Commit

Permalink
linters...
Browse files Browse the repository at this point in the history
  • Loading branch information
meemofcourse committed Jan 21, 2024
1 parent 07affaf commit abb50c8
Showing 1 changed file with 47 additions and 14 deletions.
61 changes: 47 additions & 14 deletions tgui/packages/tgui/interfaces/RequestManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ export const RequestManager = (props, context) => {
const [filteredTypes, _] = useLocalState(
context,
'filteredTypes',
Object.fromEntries(Object.entries(displayTypeMap).map(([type, _]) => [type, true]))
Object.fromEntries(
Object.entries(displayTypeMap).map(([type, _]) => [type, true])
)
);
const [searchText, setSearchText] = useLocalState(context, 'searchText');

// Handle filtering
let displayedRequests = requests.filter((request) => filteredTypes[request.req_type]);
let displayedRequests = requests.filter(
(request) => filteredTypes[request.req_type]
);
if (searchText) {
const filterText = searchText.toLowerCase();
displayedRequests = displayedRequests.filter(
(request) =>
decodeHtmlEntities(request.message)
.toLowerCase()
.includes(filterText) || request.owner_name.toLowerCase().includes(filterText)
.includes(filterText) ||
request.owner_name.toLowerCase().includes(filterText)
);
}

Expand All @@ -39,10 +44,16 @@ export const RequestManager = (props, context) => {
title="Requests"
buttons={
<>
<Input value={searchText} onInput={(_, value) => setSearchText(value)} placeholder={'Search...'} mr={1} />
<Input
value={searchText}
onInput={(_, value) => setSearchText(value)}
placeholder={'Search...'}
mr={1}
/>
<FilterPanel />
</>
}>
}
>
{displayedRequests.map((request) => (
<div className="RequestManager__row" key={request.id}>
<div className="RequestManager__rowContents">
Expand All @@ -51,7 +62,9 @@ export const RequestManager = (props, context) => {
{request.owner_name}
{request.owner === null && ' [DC]'}
</span>
<span className="RequestManager__timestamp">{request.timestamp_str}</span>
<span className="RequestManager__timestamp">
{request.timestamp_str}
</span>
</h2>
<div className="RequestManager__message">
<RequestType requestType={request.req_type} />
Expand All @@ -78,7 +91,11 @@ const displayTypeMap = {
const RequestType = (props) => {
const { requestType } = props;

return <b className={`RequestManager__${requestType}`}>{displayTypeMap[requestType]}:</b>;
return (
<b className={`RequestManager__${requestType}`}>
{displayTypeMap[requestType]}:
</b>
);
};

const RequestControls = (props, context) => {
Expand All @@ -94,19 +111,33 @@ const RequestControls = (props, context) => {
<Button onClick={() => act('tp', { id: request.id })}>TP</Button>
<Button onClick={() => act('logs', { id: request.id })}>LOGS</Button>
<Button onClick={() => act('smite', { id: request.id })}>SMITE</Button>
{request.req_type !== 'request_prayer' && <Button onClick={() => act('rply', { id: request.id })}>RPLY</Button>}
{request.req_type === 'request_nuke' && <Button onClick={() => act('setcode', { id: request.id })}>SETCODE</Button>}
{request.req_type === 'request_fax' && <Button onClick={() => act('show', { id: request.id })}>SHOW</Button>}
{request.req_type !== 'request_prayer' && (
<Button onClick={() => act('rply', { id: request.id })}>RPLY</Button>
)}
{request.req_type === 'request_nuke' && (
<Button onClick={() => act('setcode', { id: request.id })}>
SETCODE
</Button>
)}
{request.req_type === 'request_fax' && (
<Button onClick={() => act('show', { id: request.id })}>SHOW</Button>
)}
</div>
);
};

const FilterPanel = (_, context) => {
const [filterVisible, setFilterVisible] = useLocalState(context, 'filterVisible', false);
const [filterVisible, setFilterVisible] = useLocalState(
context,
'filterVisible',
false
);
const [filteredTypes, setFilteredTypes] = useLocalState(
context,
'filteredTypes',
Object.fromEntries(Object.entries(displayTypeMap).map(([type, _]) => [type, true]))
Object.fromEntries(
Object.entries(displayTypeMap).map(([type, _]) => [type, true])
)
);

return (
Expand All @@ -119,7 +150,8 @@ const FilterPanel = (_, context) => {
className="RequestManager__filterPanel"
style={{
display: filterVisible ? 'block' : 'none',
}}>
}}
>
<Table width="0">
{Object.keys(displayTypeMap).map((type) => {
return (
Expand All @@ -142,7 +174,8 @@ const FilterPanel = (_, context) => {
})}
</Table>
</div>
}>
}
>
<Button icon="cog" onClick={() => setFilterVisible(!filterVisible)}>
Type Filter
</Button>
Expand Down

0 comments on commit abb50c8

Please sign in to comment.