update secret import create notif

This commit is contained in:
Maidul Islam
2024-01-04 01:55:34 -05:00
parent 304f14c0ed
commit ba2a03897f
@@ -1,5 +1,6 @@
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { AxiosError } from "axios";
import { z } from "zod"; import { z } from "zod";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
@@ -78,12 +79,20 @@ export const CreateSecretImportForm = ({
type: "success", type: "success",
text: "Successfully linked" text: "Successfully linked"
}); });
} catch (error) { } catch (err) {
console.log(error); console.error(err);
createNotification({ const axiosError = err as AxiosError
type: "error", if (axiosError?.response?.status === 401) {
text: "Failed to link secrets" createNotification({
}); text: "You do not have access to the selected environment/path",
type: "error"
});
} else {
createNotification({
type: "error",
text: "Failed to link secrets"
});
}
} }
}; };