"use client";
import React from "react";
import PasswordResetForm from "@/components/admin/custom ui/passReset";

// MAJOR ISSUE FOUND HERE. RESET PASSWORD IS NOT WORKING. 
// FIXED BY - SHAMIR ROY

const page = ({ params }: { params: { uuid: string } }) => {

  const hadelresetpass = async (newPassword1: string, newPassword2: string) => {
    try {
      const response = await fetch(`/api/resetPassword/${params.uuid}`, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          newPassword1,
          newPassword2,
        }),
      });

      const data = await response.json()

      return { status: response.status, ...data };

    } catch (error: any) {
      throw new Error("Failed to reset password." + error.message);
    }
  };
  return (
    <div>
      <PasswordResetForm onPasswordReset={hadelresetpass} />
    </div>
  );
};

export default page;
