Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Custom Use Status Modal Issue #25120

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions client/views/admin/customUserStatus/AddCustomUserStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useMethod } from '../../../contexts/ServerContext';
import { useToastMessageDispatch } from '../../../contexts/ToastMessagesContext';
import { useTranslation } from '../../../contexts/TranslationContext';

function AddCustomUserStatus({ goToNew, close, onChange, ...props }) {
function AddCustomUserStatus({ close, onChange, ...props }) {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();

Expand All @@ -16,20 +16,20 @@ function AddCustomUserStatus({ goToNew, close, onChange, ...props }) {
const saveStatus = useMethod('insertOrUpdateUserStatus');
const handleSave = useCallback(async () => {
try {
const result = await saveStatus({
await saveStatus({
name,
statusType,
});
dispatchToastMessage({
type: 'success',
message: t('Custom_User_Status_Updated_Successfully'),
});
goToNew(result)();
close();
onChange();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
}, [dispatchToastMessage, goToNew, name, onChange, saveStatus, statusType, t]);
}, [dispatchToastMessage, name, onChange, saveStatus, statusType, t]);

const presenceOptions = [
['online', t('Online')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function CustomUserStatusRoute() {
</VerticalBar.Header>

{context === 'edit' && <EditCustomUserStatusWithData _id={id} close={handleClose} onChange={handleChange} />}
{context === 'new' && <AddCustomUserStatus goToNew={handleItemClick} close={handleClose} onChange={handleChange} />}
{context === 'new' && <AddCustomUserStatus close={handleClose} onChange={handleChange} />}
</VerticalBar>
)}
</Page>
Expand Down
3 changes: 2 additions & 1 deletion client/views/admin/customUserStatus/EditCustomUserStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function EditCustomUserStatus({ close, onChange, data, ...props }) {
type: 'success',
message: t('Custom_User_Status_Updated_Successfully'),
});
close();
onChange();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
Expand Down Expand Up @@ -107,7 +108,7 @@ export function EditCustomUserStatus({ close, onChange, data, ...props }) {
<ButtonGroup stretch w='full'>
<Button onClick={close}>{t('Cancel')}</Button>
<Button primary onClick={handleSave} disabled={!hasUnsavedChanges}>
{t('Save')}
{t('Update')}
</Button>
</ButtonGroup>
</Field.Row>
Expand Down