types#UserDetail TypeScript Examples

The following examples show how to use types#UserDetail. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Profile.test.tsx    From knboard with MIT License 6 votes vote down vote up
steveDetail: UserDetail = {
  id: 1,
  username: "steve",
  first_name: "Steve",
  last_name: "Apple",
  email: "[email protected]",
  avatar: null,
  date_joined: new Date().toISOString(),
  is_guest: false,
}
Example #2
Source File: ProfileSlice.tsx    From knboard with MIT License 6 votes vote down vote up
updateUser = createAsyncThunk<
  UserDetail,
  UserDetail,
  {
    rejectValue: ValidationErrors;
  }
>(
  "profile/updateUserStatus",
  async (userData, { dispatch, getState, rejectWithValue }) => {
    try {
      // Don't POST blank email
      if (!userData["email"]) {
        delete userData["email"];
      }
      const id = (getState() as RootState).auth.user?.id;
      const response = await api.put(`${API_USERS}${id}/`, userData);
      dispatch(createSuccessToast("User saved"));
      return response.data;
    } catch (err) {
      if (!err.response) {
        throw err;
      }

      return rejectWithValue(err.response.data);
    }
  }
)
Example #3
Source File: ProfileSlice.tsx    From knboard with MIT License 5 votes vote down vote up
fetchUserDetail = createAsyncThunk<UserDetail>(
  "profile/fetchUserDetailStatus",
  async (_, { getState }) => {
    const id = (getState() as RootState).auth.user?.id;
    const response = await api.get(`${API_USERS}${id}/`);
    return response.data;
  }
)