fleet/frontend/services/entities/mdm_csr.ts
Jacob Shandling 6c04cc24d7
UI: Settings modals mdm (#9156)
# Addresses parts 1 and 2 of #8872

[Demo (updated
1/6)](https://www.loom.com/share/be6d21cd3dfd42019a96431848ced7a3)

1/9: updated Success state with canonical Fleet icon and new copy:
<img width="669" alt="Screenshot 2023-01-09 at 5 17 58 PM"
src="https://user-images.githubusercontent.com/61553566/211440074-a69c420a-920c-40dd-a96f-f2d3917ad73a.png">

TODO:
- finalize API call once those specs are clarified and implemented:
https://github.com/fleetdm/fleet/issues/9202
- tests
- Change team modal (pt3)

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-01-10 12:19:46 -08:00

46 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { SetStateAction } from "react";
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
// import { sendRequest } from "services/mock_service/service/service"; // MDM TODO: Replace when backend is merged
import { IRequestCSRFormData } from "interfaces/request_csr";
import axios from "axios";
import local from "utilities/local";
// This API call is made to a specific endpoint that is different than our
// other ones. This is why we have implmented the call with axios here instead
// of using our sendRequest method.
const requestCSR = async (
formData: IRequestCSRFormData,
setRequestState: React.Dispatch<
SetStateAction<"loading" | "error" | "success" | "invalid" | undefined>
>
) => {
setRequestState("loading");
const token = local.getItem("auth_token");
const url = "https://www.fleetdm.com/api/v1/get_signed_apns_csr";
try {
// await axios({
// method: "post",
// url,
// data: formData,
// responseType: "json",
// headers: {
// Authorization: `Bearer ${token}`,
// },
// });
alert(
"Dummy success placeholder did not actually request from API (which is WIP)"
);
setRequestState("success");
} catch (error) {
if (error === "invalid") {
setRequestState("invalid");
} else {
setRequestState("error");
}
// const axiosError = error as AxiosError;
// return axiosError.response;
}
};
export default requestCSR;