mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
🆙 Init V3
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { DesktopViewEvent, GetSessionDataManager } from '@nitrots/nitro-renderer';
|
||||
import { FC, useState } from 'react';
|
||||
import { FaChevronDown, FaChevronUp } from 'react-icons/fa';
|
||||
import { Flex, Text } from '../../../../common';
|
||||
import { useMessageEvent, useRoomPromote } from '../../../../hooks';
|
||||
import { RoomPromoteEditWidgetView, RoomPromoteMyOwnEventWidgetView, RoomPromoteOtherEventWidgetView } from './views';
|
||||
|
||||
export const RoomPromotesWidgetView: FC<{}> = props =>
|
||||
{
|
||||
const [ isEditingPromote, setIsEditingPromote ] = useState<boolean>(false);
|
||||
const [ isOpen, setIsOpen ] = useState<boolean>(true);
|
||||
const { promoteInformation, setPromoteInformation } = useRoomPromote();
|
||||
|
||||
useMessageEvent<DesktopViewEvent>(DesktopViewEvent, event =>
|
||||
{
|
||||
setPromoteInformation(null);
|
||||
});
|
||||
|
||||
if(!promoteInformation) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{ promoteInformation.data.adId !== -1 &&
|
||||
<div className="px-[5px] py-[6px] [box-shadow:inset_0_5px_#22222799,_inset_0_-4px_#12121599] text-sm bg-[#1c1c20f2] rounded">
|
||||
<div className="flex flex-col">
|
||||
<Flex pointer alignItems="center" justifyContent="between" onClick={ event => setIsOpen(value => !value) }>
|
||||
<Text overflow="hidden" variant="white">{ promoteInformation.data.eventName }</Text>
|
||||
{ isOpen && <FaChevronUp className="fa-icon" /> }
|
||||
{ !isOpen && <FaChevronDown className="fa-icon" /> }
|
||||
</Flex>
|
||||
{ (isOpen && GetSessionDataManager().userId !== promoteInformation.data.ownerAvatarId) &&
|
||||
<RoomPromoteOtherEventWidgetView
|
||||
eventDescription={ promoteInformation.data.eventDescription }
|
||||
/>
|
||||
}
|
||||
{ (isOpen && GetSessionDataManager().userId === promoteInformation.data.ownerAvatarId) &&
|
||||
<RoomPromoteMyOwnEventWidgetView
|
||||
eventDescription={ promoteInformation.data.eventDescription }
|
||||
setIsEditingPromote={ () => setIsEditingPromote(true) }
|
||||
/>
|
||||
}
|
||||
{ isEditingPromote &&
|
||||
<RoomPromoteEditWidgetView
|
||||
eventDescription={ promoteInformation.data.eventDescription }
|
||||
eventId={ promoteInformation.data.adId }
|
||||
eventName={ promoteInformation.data.eventName }
|
||||
setIsEditingPromote={ () => setIsEditingPromote(false) }
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
import { EditEventMessageComposer } from '@nitrots/nitro-renderer';
|
||||
import { FC, useState } from 'react';
|
||||
import { LocalizeText, SendMessageComposer } from '../../../../../api';
|
||||
import { Button, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common';
|
||||
import { NitroInput } from '../../../../../layout';
|
||||
|
||||
interface RoomPromoteEditWidgetViewProps
|
||||
{
|
||||
eventId: number;
|
||||
eventName: string;
|
||||
eventDescription: string;
|
||||
setIsEditingPromote: (value: boolean) => void;
|
||||
}
|
||||
|
||||
export const RoomPromoteEditWidgetView: FC<RoomPromoteEditWidgetViewProps> = props =>
|
||||
{
|
||||
const { eventId = -1, eventName = '', eventDescription = '', setIsEditingPromote = null } = props;
|
||||
const [ newEventName, setNewEventName ] = useState<string>(eventName);
|
||||
const [ newEventDescription, setNewEventDescription ] = useState<string>(eventDescription);
|
||||
|
||||
const updatePromote = () =>
|
||||
{
|
||||
SendMessageComposer(new EditEventMessageComposer(eventId, newEventName, newEventDescription));
|
||||
setIsEditingPromote(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-guide-tool" theme="primary-slim">
|
||||
<NitroCardHeaderView headerText={ LocalizeText('navigator.eventsettings.editcaption') } onCloseClick={ () => setIsEditingPromote(false) } />
|
||||
<NitroCardContentView className="text-black">
|
||||
<div className="flex flex-col">
|
||||
<Text bold>{ LocalizeText('navigator.eventsettings.name') }</Text>
|
||||
<NitroInput maxLength={ 64 } placeholder={ LocalizeText('navigator.eventsettings.name') } type="text" value={ newEventName } onChange={ event => setNewEventName(event.target.value) } />
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<Text bold>{ LocalizeText('navigator.eventsettings.desc') }</Text>
|
||||
<textarea className="min-h-[calc(1.5em+ .5rem+2px)] px-[.5rem] py-[.25rem] rounded-[.2rem] form-control-sm" maxLength={ 64 } placeholder={ LocalizeText('navigator.eventsettings.desc') } value={ newEventDescription } onChange={ event => setNewEventDescription(event.target.value) }></textarea>
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<Button fullWidth disabled={ !newEventName || !newEventDescription } variant={ (!newEventName || !newEventDescription) ? 'danger' : 'success' } onClick={ event => updatePromote() }>{ LocalizeText('navigator.eventsettings.edit') }</Button>
|
||||
</div>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { CreateLinkEvent } from '@nitrots/nitro-renderer';
|
||||
import { FC } from 'react';
|
||||
import { LocalizeText } from '../../../../../api';
|
||||
import { Button, Flex, Grid, Text } from '../../../../../common';
|
||||
import { useRoomPromote } from '../../../../../hooks';
|
||||
|
||||
interface RoomPromoteMyOwnEventWidgetViewProps
|
||||
{
|
||||
eventDescription: string;
|
||||
setIsEditingPromote: (value: boolean) => void;
|
||||
}
|
||||
|
||||
export const RoomPromoteMyOwnEventWidgetView: FC<RoomPromoteMyOwnEventWidgetViewProps> = props =>
|
||||
{
|
||||
const { eventDescription = '', setIsEditingPromote = null } = props;
|
||||
const { setIsExtended } = useRoomPromote();
|
||||
|
||||
const extendPromote = () =>
|
||||
{
|
||||
setIsExtended(true);
|
||||
CreateLinkEvent('catalog/open/room_event');
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flex alignItems="center" gap={ 2 } style={ { overflowWrap: 'anywhere' } }>
|
||||
<Text variant="white">{ eventDescription }</Text>
|
||||
</Flex>
|
||||
<br /><br />
|
||||
<Grid className="flex items-center justify-end gap-2">
|
||||
<Button className="btn btn-primary w-full btn-sm" onClick={ event => setIsEditingPromote(true) }>{ LocalizeText('navigator.roominfo.editevent') }</Button>
|
||||
<Button className="btn btn-success w-full btn-sm" onClick={ event => extendPromote() }>{ LocalizeText('roomad.extend.event') }</Button>
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
import { FC } from 'react';
|
||||
import { LocalizeText } from '../../../../../api';
|
||||
import { Column, Flex, Text } from '../../../../../common';
|
||||
|
||||
interface RoomPromoteOtherEventWidgetViewProps
|
||||
{
|
||||
eventDescription: string;
|
||||
}
|
||||
|
||||
export const RoomPromoteOtherEventWidgetView: FC<RoomPromoteOtherEventWidgetViewProps> = props =>
|
||||
{
|
||||
const { eventDescription = '' } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flex alignItems="center" gap={ 2 } style={ { overflowWrap: 'anywhere' } }>
|
||||
<Text variant="white">{ eventDescription }</Text>
|
||||
</Flex>
|
||||
<br /><br />
|
||||
<Column alignItems="center" gap={ 1 }>
|
||||
<div className="bg-light-dark rounded relative overflow-hidden w-full">
|
||||
<div className="flex justify-center items-center size-full absolute">
|
||||
<Text center variant="white">{ LocalizeText('navigator.eventinprogress') }</Text>
|
||||
</div>
|
||||
<Text> </Text>
|
||||
</div>
|
||||
</Column>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './RoomPromoteEditWidgetView';
|
||||
export * from './RoomPromoteMyOwnEventWidgetView';
|
||||
export * from './RoomPromoteOtherEventWidgetView';
|
||||
Reference in New Issue
Block a user