當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript react-toastify.toast類代碼示例

本文整理匯總了TypeScript中react-toastify.toast的典型用法代碼示例。如果您正苦於以下問題:TypeScript toast類的具體用法?TypeScript toast怎麽用?TypeScript toast使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了toast類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: ChangePasswordToken

function* ChangePasswordToken(action: any): SagaIterator {
  try {
    const { token, password } = action.payload
    yield put(Actions.LoadingPage.onLoadingOn())

    const data = yield call(ChangePasswordTokenFrost, token, password)
    yield put(Actions.ChangePasswordToken.onChangePasswordTokenSuccess(data))

    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.SignOut.onSignOut({ redirectLogin: false }))
    yield put(Actions.SetTokenLogin.onSetTokenLogin(data))

    yield call(delay, 1000)

    browserHistory.push('/dashboard')

    toast.success('Your password has been updated!', {
      className: 'toast',
      autoClose: 2500,
    })
  } catch (e) {
    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.ChangePasswordToken.onChangePasswordTokenError(e))
    yield call(delay, 300)
    yield put(Actions.ChangePasswordToken.onChangePasswordTokenClearError())

    toast.error(e, {
      className: 'toast',
      autoClose: 2500,
    })
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:32,代碼來源:ChangePasswordToken.saga.ts

示例2: VerifiedAccount

function* VerifiedAccount(action: any): SagaIterator {
  const toastId = toast.info('Verifying account...', {
    className: 'toast',
  })

  try {
    const { token, password } = action.payload
    yield put(Actions.LoadingPage.onLoadingOn())

    const data = yield call(GetApiTokensFrost, token, password)
    yield put(Actions.VerifiedAccount.onVerifiedAccountSuccess())

    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.SignOut.onSignOut({ redirectLogin: false }))
    yield put(Actions.SetTokenLogin.onSetTokenLogin(data))

    yield call(delay, 1000)

    browserHistory.push('/dashboard')

    toast.success('Your account has been verified!', {
      className: 'toast',
      autoClose: 2500,
    })
  } catch (e) {
    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.VerifiedAccount.onVerifiedAccountError(e))
    yield call(delay, 300)
    yield put(Actions.VerifiedAccount.onVerifiedAccountClearError())

    if (e.includes('Email already verified')) {
      browserHistory.push('/dashboard')
      toast.info(e, {
        className: 'toast',
        autoClose: 2500,
      })
    } else if (e.includes('Expired token')) {
      const message = 'This link has expired. Please login and request a new validation email.'
      toast.update(toastId, {
        render: message,
        type: toast.TYPE.ERROR,
        className: 'toast',
        autoClose: false,
      })
    } else
      toast.update(toastId, {
        render: e,
        type: toast.TYPE.ERROR,
        autoClose: false,
        className: 'toast',
      })
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:53,代碼來源:VerifiedAccount.saga.ts

示例3: GetApiTokens

function* GetApiTokens(action: any): SagaIterator {
  try {
    yield put(Actions.LoadingPage.onLoadingOn())
    yield put(Actions.NotificationBar.onResetNotificationBar())
    const { token } = action.payload
    const { apiToken } = yield call(CreateApiTokenFrost, token)
    yield put(Actions.ApiTokens.onCreateApiTokenSuccess(apiToken))
    yield put(
      Actions.NotificationBar.onShowNotificationBar({
        type: 'success',
        message: 'API TOKEN SUCCESSFULLY CREATED',
      })
    )
    yield put(Actions.LoadingPage.onLoadingFull())
    yield call(delay, 2000)
    yield put(Actions.NotificationBar.onHideNotificationBar())
    yield call(delay, 2000)
    yield put(Actions.NotificationBar.onResetNotificationBar())
  } catch (e) {
    yield put(Actions.ApiTokens.onCreateApiTokenError(e))
    yield put(Actions.LoadingPage.onLoadingFull())
    const errorMessage = typeof e === 'object' ? e.message : e
    toast.error(errorMessage, {
      className: 'toast',
      autoClose: 2500,
    })
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:28,代碼來源:CreateApiToken.saga.ts

示例4: onError

const errorLink = onError(({ graphQLErrors, networkError }) => {
  if (graphQLErrors) {
    graphQLErrors.map(({ message }) => {
      toast.error(`Unexpected error: ${message}`);
    });
  }
  if (networkError) {
    toast.error(`Network error: ${networkError}`);
  }
});
開發者ID:piann,項目名稱:weber-client,代碼行數:10,代碼來源:apollo.ts

示例5: if

 .then(response => {
   if (action.meta && action.meta.successMessage) {
     toast.success(action.meta.successMessage);
   } else if (response && response.action && response.action.payload && response.action.payload.headers) {
     const headers = response.action.payload.headers;
     let alert: string = null;
     let alertParams: string = null;
     Object.entries(headers).forEach(([k, v]: [string, string]) => {
       if (k.endsWith('app-alert')) {
         alert = v;
       } else if (k.endsWith('app-params')) {
         alertParams = v;
       }
     });
     if (alert) {
       const alertParam = alertParams;
       toast.success(translate(alert, { param: alertParam }));
     }
   }
   return Promise.resolve(response);
 })
開發者ID:gjik911,項目名稱:git_01,代碼行數:21,代碼來源:notification-middleware.ts

示例6: async

export const reverseGeoCode = async (lat:number, lng:number) => {
    const API_URL =  `https://maps.googleapis.com/maps/api/geocode/json?language=ko&latlng=${lat},${lng}&key=${MAPS_KEY}`;
    const {status, data} = await axois(API_URL);
    if(status===200 && !data.error_message){
        const {results} = data;
        const firstPlace = results[0];
        const address = firstPlace.formatted_address;
        return address;
    } else {
        toast.error(data.error_message || "Some Unknown Error Happened", {hideProgressBar:true});
        return false;
    }

}
開發者ID:piann,項目名稱:weber-client,代碼行數:14,代碼來源:mapHelpers.ts

示例7: DeleteApiToken

function* DeleteApiToken(action: any): SagaIterator {
  try {
    const { token, apiToken } = action.payload
    yield put(Actions.LoadingPage.onLoadingOn())
    yield call(DeleteApiTokenFrost, token, apiToken)
    yield put(Actions.DeleteApiToken.onDeleteApiTokenSuccess(apiToken))
    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.Modal.onHideModal())
    yield call(delay, 300)
  } catch (e) {
    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.DeleteApiToken.onDeleteApiTokenError(e))
    const errorMessage = typeof e === 'object' ? e.message : e
    toast.error(errorMessage, {
      className: 'toast',
      autoClose: 2500,
    })
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:19,代碼來源:DeleteApiToken.saga.ts

示例8: SignIn

function* SignIn(action: any): SagaIterator {
  try {
    const { email, password } = action.payload
    yield put(Actions.LoadingPage.onLoadingOn())
    const { token } = yield call(signInFrost, { email, password })
    yield put(Actions.SignIn.onSignInSuccess({ token, ...{ profile: { email } } }))
    yield put(Actions.Profile.onProfile({ token }))
    yield put(Actions.LoadingPage.onLoadingFull())
    yield call(delay, 300)
    browserHistory.push('/dashboard')
  } catch (e) {
    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.SignIn.onSignInError(e))
    yield call(delay, 300)
    yield put(Actions.SignIn.onSignInClearError())
    toast.error(e, {
      className: 'toast',
      autoClose: 2500,
    })
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:21,代碼來源:SignIn.saga.ts

示例9:

 graphQLErrors.map(({ message }) => {
   toast.error(`Unexpected error: ${message}`);
 });
開發者ID:piann,項目名稱:weber-client,代碼行數:3,代碼來源:apollo.ts


注:本文中的react-toastify.toast類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。