mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Fix change name modal story not rendering. Closes #2255
This commit is contained in:
parent
d95ad34eee
commit
b9f5b1da19
@ -1,20 +1,41 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||
import { NameChangeModal } from './NameChangeModal';
|
||||
import { CurrentUser } from '../../../interfaces/current-user';
|
||||
import { currentUserAtom } from '../../stores/ClientConfigStore';
|
||||
|
||||
export default {
|
||||
title: 'owncast/Modals/Name change',
|
||||
title: 'owncast/Modals/Name Change',
|
||||
component: NameChangeModal,
|
||||
parameters: {},
|
||||
} as ComponentMeta<typeof NameChangeModal>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const Template: ComponentStory<typeof NameChangeModal> = args => (
|
||||
const Example = () => {
|
||||
const setCurrentUser = useSetRecoilState<CurrentUser>(currentUserAtom);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
setCurrentUser({
|
||||
id: '1',
|
||||
displayName: 'Test User',
|
||||
displayColor: 3,
|
||||
isModerator: false,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<NameChangeModal />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const Template: ComponentStory<typeof NameChangeModal> = () => (
|
||||
<RecoilRoot>
|
||||
<NameChangeModal />
|
||||
<Example />
|
||||
</RecoilRoot>
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export const Basic = Template.bind({});
|
||||
|
@ -23,13 +23,14 @@ const UserColor: FC<UserColorProps> = ({ color }) => {
|
||||
|
||||
export const NameChangeModal: FC = () => {
|
||||
const currentUser = useRecoilValue(currentUserAtom);
|
||||
const websocketService = useRecoilValue<WebsocketService>(websocketServiceAtom);
|
||||
const [newName, setNewName] = useState<string>(currentUser?.displayName);
|
||||
|
||||
if (!currentUser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { displayName, displayColor } = currentUser;
|
||||
const websocketService = useRecoilValue<WebsocketService>(websocketServiceAtom);
|
||||
const [newName, setNewName] = useState<any>(displayName);
|
||||
|
||||
const handleNameChange = () => {
|
||||
const nameChange = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user