mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
6c04cc24d7
# 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>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
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;
|