import React from 'react'
import { Tooltip } from 'antd'
import Modal from '../../components/core/Modal'
import arcmIcons from '../../Icons'
import { useArchivedOrder } from '../../context/ArchivedOrderContext'

const ArchivedOrderModals = () => {
  const {
    // Modal states
    modalLoading,
    isOpenUnarchiveModal,
    isStartUnarchiveModal,
    modalTile,
    modaDesc,
    isUnarchiveCancelModal,
    cancelUnarchiveBtnLoading,
    unArchvedOrder,
    totalUnArchvedOrder,
    isUnarchiveCancel,
    selectedOrders,
    exportFileName,
    exportFormat,
    setExportFormat,
    exportSortType,
    setExportSortType,
    isOpenExportModal,
    isOpenExportCancelModal,
    cancelExportBtnLoading,
    isEmptyOrderModal,
    emptyOrderTitle,
    isOpenDeleteConfirmModal,
    duplicateOrders,
    duplicatOrderText,
    isSyncModalOpen,
    syncLoading,
    ordserListTxt,
    isPro,
    setExportFileName,
    setIsOpenDeleteConfirmModal,

    // Modal functions
    handleUnarchiveModal,
    showBulkDuplicateModal,
    handleDuplicateModal,
    handleContinueUnarchive,
    handleCancelUnarchive,
    proceedDuplicateBgUnArchiving,
    proceedBgUnArchiving,
    handleStartUnarchiveModal,
    handlePermanentDelete,
    handleIsOpenExportModal,
    exportOrder,
    handleExportCancelModal,
    handelCancelExporting,
    handleUnarchiveCancelModal,
    handelCancelUnarchiving,
    handleIsEmptyOrderModal,
    handleSyncModal,
    handleSyncArchiveData,
    flashDoor,
    isOpenDuplicateModal,
    deleteLoading,

    // Translation
    t
  } = useArchivedOrder()

  return (
    <>
      {/* Unarchive Progress Modal */}
      <Modal
        openModal={isOpenUnarchiveModal}
        toggleModal={handleUnarchiveModal}
        outerClick={false}
      >
        {{
          header: !modalLoading ? <div></div> : '',
          body: modalLoading ? (
            <div className='arcm-text-center arcm-mb-6'>
              <div className='icon arcm-inline-flex'>
                {arcmIcons.SpinningAnimation}
              </div>
              <h5 className='arcm-text-gray-900 arcm-text-base arcm-font-semibold arcm-mb-1.5'>
                {modalTile}
              </h5>
              <p className='arcm-text-center arcm-text-gray-900 arcm-text-sm arcm-font-normal arcm-mb-6'>
                {modaDesc}
              </p>
            </div>
          ) : (
            <div className='arcm-text-center arcm-my-6'>
              <div className='icon arcm-inline-flex arcm-mb-6'>
                <svg
                  xmlns='http://www.w3.org/2000/svg'
                  width='60'
                  height='60'
                  viewBox='0 0 60 60'
                  fill='none'
                >
                  <path
                    d='M30 60C46.5685 60 60 46.5685 60 30C60 13.4315 46.5685 0 30 0C13.4315 0 0 13.4315 0 30C0 46.5685 13.4315 60 30 60Z'
                    fill='#27D935'
                  />
                  <path
                    d='M30 60C46.5685 60 60 46.5685 60 30C60 13.4315 46.5685 0 30 0C13.4315 0 0 13.4315 0 30C0 46.5685 13.4315 60 30 60Z'
                    fill='#27D935'
                  />
                  <path
                    fillRule='evenodd'
                    clipRule='evenodd'
                    d='M14.5801 31.414L24.5801 41.414C25.3601 42.196 26.6281 42.196 27.4081 41.414L45.4081 23.414C46.1881 22.634 46.1881 21.366 45.4081 20.586C44.6281 19.806 43.3601 19.806 42.5801 20.586L25.9941 37.172L17.4081 28.586C16.6281 27.806 15.3601 27.806 14.5801 28.586C13.8001 29.366 13.8001 30.634 14.5801 31.414Z'
                    fill='white'
                  />
                </svg>
              </div>
              <h5 className='arcm-text-gray-900 arcm-text-base arcm-font-semibold arcm-mb-1.5'>
                {modalTile}
              </h5>
              <button
                onClick={() => {
                  handleUnarchiveModal()
                  showBulkDuplicateModal()
                }}
                className='arcm-text-white arcm-text-sm arcm-font-semibold arcm-px-4 arcm-py-3 arcm-min-w-[120px] arcm-bg-[#3858e9] arcm-rounded-lg arcm-justify-center arcm-items-center arcm-gap-2 arcm-inline-flex arcm-transition-all hover:arcm-bg-blue-700'
              >
                <span>{t('ok')}</span>
              </button>
            </div>
          )
        }}
      </Modal>

      {/* Duplicate Orders Warning Modal */}
      <Modal
        openModal={isOpenDuplicateModal}
        toggleModal={handleDuplicateModal}
        outerClick={false}
      >
        {{
          header: (
            <div className='arcm-text-left arcm-mb-1'>
              <h5 className='arcm-text-[#EF4444] arcm-text-lg arcm-font-semibold'>
                {t('duplicate_orders_detected')}
              </h5>
            </div>
          ),
          body: (
            <div className='arcm-text-left'>
              <p
                dangerouslySetInnerHTML={{ __html: duplicatOrderText }}
                className='arcm-text-gray-700 arcm-text-[16px] arcm-font-normal arcm-mb-4'
              ></p>

              {duplicateOrders.length > 0 && (
                <div className='arcm-mb-6 arcm-text-left arcm-rounded-lg'>
                  <p className='arcm-text-sm arcm-text-gray-800 arcm-mb-2'>
                    {ordserListTxt}:
                  </p>
                  <ul className='arcm-text-[16px] arcm-text-gray-600 arcm-max-h-[200px] arcm-overflow-hidden arcm-overflow-y-auto arcm-list-inside arcm-space-y-1'>
                    {duplicateOrders.map((order, index) => (
                      <li className='arcm-text-[16px]' key={index}>
                        - #{order.archived_order_id}
                      </li>
                    ))}
                  </ul>
                </div>
              )}

              <div className='arcm-flex arcm-justify-between arcm-mb-4'>
                {/* Unarchive */}
                <div className='arcm-relative arcm-group'>
                  {duplicateOrders.length > 0 ? (
                    <button
                      onClick={proceedDuplicateBgUnArchiving}
                      className='arcm-text-[13px] arcm-font-semibold arcm-px-7 arcm-py-3 arcm-min-w-[125px] arcm-border-2 arcm-border-[#EF4444] arcm-text-[#EF4444] arcm-rounded-lg arcm-justify-center arcm-items-center arcm-gap-2 arcm-inline-flex arcm-transition-all'
                    >
                      {t('unarchive_with_new_id')}
                    </button>
                  ) : (
                    <button
                      onClick={handleContinueUnarchive}
                      className='arcm-text-[13px] arcm-font-semibold arcm-px-7 arcm-py-3 arcm-min-w-[125px] arcm-border-2 arcm-border-[#EF4444] arcm-text-[#EF4444] arcm-rounded-lg arcm-justify-center arcm-items-center arcm-gap-2 arcm-inline-flex arcm-transition-all'
                    >
                      {t('unarchive_with_new_id')}
                    </button>
                  )}
                  <div className='arcm-absolute -arcm-bottom-[74px] arcm-right-[20px] arcm-bg-white arcm-border arcm-rounded-md arcm-p-2 arcm-text-[13px] arcm-w-[278px] arcm-opacity-0 arcm-invisible group-hover:arcm-opacity-100 group-hover:arcm-visible arcm-transition-all arcm-duration-300 arcm-z-10'>
                    {t('duplicate_unarchive_notice')}
                  </div>
                </div>

                {/* Skip Unarchiving */}
                <div className='arcm-relative arcm-group'>
                  <button
                    onClick={handleCancelUnarchive}
                    className='arcm-text-white arcm-text-[13px] arcm-font-semibold arcm-px-7 arcm-py-3 arcm-min-w-[125px] arcm-bg-[#3858E9] arcm-rounded-lg arcm-justify-center arcm-items-center arcm-gap-2 arcm-inline-flex arcm-transition-all'
                  >
                    {t('close_skip_unarchiving')}
                  </button>
                  <div className='arcm-absolute -arcm-bottom-[74px] arcm-left-[20px] arcm-bg-white arcm-border arcm-rounded-md arcm-p-2 arcm-text-[13px] arcm-w-[278px] arcm-opacity-0 arcm-invisible group-hover:arcm-opacity-100 group-hover:arcm-visible arcm-transition-all arcm-duration-300 arcm-z-10'>
                    {t('duplicate_skip_notice')}
                  </div>
                </div>
              </div>
            </div>
          )
        }}
      </Modal>

      {/* Export option Modal */}
      <Modal
        openModal={isOpenExportModal}
        toggleModal={handleIsOpenExportModal}
        outerClick={false}
      >
        {{
          header: (
            <div className='arcm-text-left arcm-mb-1'>
              <h5 className='arcm-text-black arcm-mt-3 arcm-text-lg arcm-font-semibold'>
                {t('export_archived_orders')}
              </h5>
            </div>
          ),
          body: (
            <div className='arcm-text-left'>
              <p className=' arcm-text-black arcm-mb-6 arcm-text-base'>
                {t('export_description')}
              </p>
              <div className='arcm-form-group arcm-mb-6'>
                <label className='arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-block arcm-mb-3'>
                  <span className='arcm-mr-2 arcm-align-[2px]'>
                    {t('exported_file_name')}
                  </span>
                  <Tooltip
                    className=' arcm-text-sm'
                    placement='top'
                    title={t('exported_file_name_tooltip')}
                    color='#fff'
                  >
                    <span className='icon arcm-inline-flex'>
                      <svg
                        xmlns='http://www.w3.org/2000/svg'
                        width='14'
                        height='13'
                        viewBox='0 0 14 13'
                        fill='none'
                      >
                        <path
                          fillRule='evenodd'
                          clipRule='evenodd'
                          d='M13.4001 6.49998C13.4001 10.0346 10.5347 12.9 7.0001 12.9C3.46548 12.9 0.600098 10.0346 0.600098 6.49998C0.600098 2.96535 3.46548 0.0999756 7.0001 0.0999756C10.5347 0.0999756 13.4001 2.96535 13.4001 6.49998ZM6.15157 4.05143C5.91725 4.28574 5.53736 4.28574 5.30304 4.05143C5.06873 3.81711 5.06873 3.43721 5.30304 3.2029C6.2403 2.26564 7.75989 2.26564 8.69715 3.2029C9.63441 4.14016 9.63441 5.65975 8.69715 6.59701C8.38317 6.911 8.00238 7.12048 7.6001 7.22404V7.49995C7.6001 7.83132 7.33147 8.09995 7.0001 8.09995C6.66873 8.09995 6.4001 7.83132 6.4001 7.49995V7.09995C6.4001 6.52372 6.85605 6.16258 7.26517 6.07055C7.47868 6.02252 7.68138 5.91573 7.84863 5.74848C8.31725 5.27985 8.31725 4.52006 7.84863 4.05143C7.38 3.5828 6.6202 3.5828 6.15157 4.05143ZM7.0001 10.5C7.44192 10.5 7.8001 10.1418 7.8001 9.69998C7.8001 9.25815 7.44192 8.89997 7.0001 8.89997C6.55827 8.89997 6.2001 9.25815 6.2001 9.69998C6.2001 10.1418 6.55827 10.5 7.0001 10.5Z'
                          fill='#D1D5DB'
                        />
                      </svg>
                    </span>
                  </Tooltip>
                </label>
                <input
                  value={
                    exportFileName ? exportFileName : t('exporting_file_name')
                  }
                  type='text'
                  className='arcm-max-w-[489px] !arcm-p-4 !arcm-bg-white !arcm-rounded-lg !arcm-border !arcm-border-gray-400 !arcm-text-gray-900 !arcm-text-sm !arcm-font-normal !arcm-shadow-none placeholder:!arcm-text-gray-400 !arcm-w-full'
                  onChange={e => {
                    setExportFileName(e.target.value)
                  }}
                />
              </div>
              <div className='arcm-form-group arcm-mb-6'>
                <label className='arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-block arcm-mb-3'>
                  <span className='arcm-mr-2 arcm-align-[2px]'>
                    {t('sort_orders')}
                  </span>
                  <Tooltip
                    className=' arcm-text-sm'
                    placement='top'
                    title={t('sort_orders_tooltip')}
                    color='#fff'
                  >
                    <span className='icon arcm-inline-flex'>
                      <svg
                        xmlns='http://www.w3.org/2000/svg'
                        width='14'
                        height='13'
                        viewBox='0 0 14 13'
                        fill='none'
                      >
                        <path
                          fillRule='evenodd'
                          clipRule='evenodd'
                          d='M13.4001 6.49998C13.4001 10.0346 10.5347 12.9 7.0001 12.9C3.46548 12.9 0.600098 10.0346 0.600098 6.49998C0.600098 2.96535 3.46548 0.0999756 7.0001 0.0999756C10.5347 0.0999756 13.4001 2.96535 13.4001 6.49998ZM6.15157 4.05143C5.91725 4.28574 5.53736 4.28574 5.30304 4.05143C5.06873 3.81711 5.06873 3.43721 5.30304 3.2029C6.2403 2.26564 7.75989 2.26564 8.69715 3.2029C9.63441 4.14016 9.63441 5.65975 8.69715 6.59701C8.38317 6.911 8.00238 7.12048 7.6001 7.22404V7.49995C7.6001 7.83132 7.33147 8.09995 7.0001 8.09995C6.66873 8.09995 6.4001 7.83132 6.4001 7.49995V7.09995C6.4001 6.52372 6.85605 6.16258 7.26517 6.07055C7.47868 6.02252 7.68138 5.91573 7.84863 5.74848C8.31725 5.27985 8.31725 4.52006 7.84863 4.05143C7.38 3.5828 6.6202 3.5828 6.15157 4.05143ZM7.0001 10.5C7.44192 10.5 7.8001 10.1418 7.8001 9.69998C7.8001 9.25815 7.44192 8.89997 7.0001 8.89997C6.55827 8.89997 6.2001 9.25815 6.2001 9.69998C6.2001 10.1418 6.55827 10.5 7.0001 10.5Z'
                          fill='#D1D5DB'
                        />
                      </svg>
                    </span>
                  </Tooltip>
                </label>

                <div className='arcm-radio-fields arcm-flex arcm-flex-wrap arcm-items-center arcm-gap-4 arcm-max-w-[332px]'>
                  <label
                    htmlFor='arcm-ascending'
                    className=" arcm-grow arcm-shrink arcm-basis-[158px] arcm-radio arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-p-5 arcm-pl-[52px] arcm-bg-white arcm-rounded-lg arcm-relative arcm-min-w-[50px] arcm-items-center arcm-inline-flex arcm-cursor-pointer after:arcm-content-[''] after:arcm-w-5 after:arcm-h-5 after:arcm-border after:arcm-rounded-full after:arcm-border-gray-400 after:arcm-absolute after:arcm-left-6 before:arcm-content-[''] before:arcm-w-3 before:arcm-h-3 before:arcm-rounded-full before:arcm-bg-transparent before:arcm-absolute before:arcm-left-7 arcm-transition-all has-[:checked]:before:arcm-bg-[#3858e9] has-[:checked]:after:arcm-border-[#3858e9] arcm-border-2 arcm-border-[#e3e3e3]"
                  >
                    <input
                      type='radio'
                      id='arcm-ascending'
                      className='!arcm-hidden'
                      name='sort-orders'
                      value='ASC'
                      checked={exportSortType === 'ASC'}
                      onChange={e => {
                        setExportSortType(e.target.value)
                      }}
                    />
                    <span>{t('ascending')}</span>
                  </label>

                  <label
                    htmlFor='arcm-descending'
                    className=" arcm-grow arcm-shrink arcm-basis-[158px] arcm-radio arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-p-5 arcm-pl-[52px] arcm-bg-white arcm-rounded-lg arcm-relative arcm-min-w-[50px] arcm-items-center arcm-inline-flex arcm-cursor-pointer after:arcm-content-[''] after:arcm-w-5 after:arcm-h-5 after:arcm-border after:arcm-rounded-full after:arcm-border-gray-400 after:arcm-absolute after:arcm-left-6 before:arcm-content-[''] before:arcm-w-3 before:arcm-h-3 before:arcm-rounded-full before:arcm-bg-transparent before:arcm-absolute before:arcm-left-7 arcm-transition-all has-[:checked]:before:arcm-bg-[#3858e9] has-[:checked]:after:arcm-border-[#3858e9] arcm-border-2 arcm-border-[#e3e3e3]"
                  >
                    <input
                      type='radio'
                      id='arcm-descending'
                      name='sort-orders'
                      className='!arcm-hidden'
                      value='DESC'
                      checked={exportSortType === 'DESC'}
                      onChange={e => {
                        setExportSortType(e.target.value)
                      }}
                    />
                    <span>{t('descending')}</span>
                  </label>
                </div>
              </div>

              <div className='arcm-form-group arcm-mb-4'>
                <label className='arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-block arcm-mb-3'>
                  <span className='arcm-mr-2 arcm-align-[2px]'>
                    {t('select_export_format')}
                  </span>
                  <Tooltip
                    className=' arcm-text-sm'
                    placement='top'
                    title={t('select_export_format_tooltip')}
                    color='#fff'
                  >
                    <span className='icon arcm-inline-flex'>
                      <svg
                        xmlns='http://www.w3.org/2000/svg'
                        width='14'
                        height='13'
                        viewBox='0 0 14 13'
                        fill='none'
                      >
                        <path
                          fillRule='evenodd'
                          clipRule='evenodd'
                          d='M13.4001 6.49998C13.4001 10.0346 10.5347 12.9 7.0001 12.9C3.46548 12.9 0.600098 10.0346 0.600098 6.49998C0.600098 2.96535 3.46548 0.0999756 7.0001 0.0999756C10.5347 0.0999756 13.4001 2.96535 13.4001 6.49998ZM6.15157 4.05143C5.91725 4.28574 5.53736 4.28574 5.30304 4.05143C5.06873 3.81711 5.06873 3.43721 5.30304 3.2029C6.2403 2.26564 7.75989 2.26564 8.69715 3.2029C9.63441 4.14016 9.63441 5.65975 8.69715 6.59701C8.38317 6.911 8.00238 7.12048 7.6001 7.22404V7.49995C7.6001 7.83132 7.33147 8.09995 7.0001 8.09995C6.66873 8.09995 6.4001 7.83132 6.4001 7.49995V7.09995C6.4001 6.52372 6.85605 6.16258 7.26517 6.07055C7.47868 6.02252 7.68138 5.91573 7.84863 5.74848C8.31725 5.27985 8.31725 4.52006 7.84863 4.05143C7.38 3.5828 6.6202 3.5828 6.15157 4.05143ZM7.0001 10.5C7.44192 10.5 7.8001 10.1418 7.8001 9.69998C7.8001 9.25815 7.44192 8.89997 7.0001 8.89997C6.55827 8.89997 6.2001 9.25815 6.2001 9.69998C6.2001 10.1418 6.55827 10.5 7.0001 10.5Z'
                          fill='#D1D5DB'
                        />
                      </svg>
                    </span>
                  </Tooltip>
                </label>

                <div className='arcm-radio-fields arcm-flex arcm-flex-wrap arcm-items-center arcm-gap-4 arcm-max-w-[680px]'>
                  <label
                    htmlFor='arcm-json'
                    className=" arcm-grow arcm-shrink arcm-radio arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-p-5 arcm-pl-[52px] arcm-bg-white arcm-rounded-lg arcm-relative arcm-min-w-[50px] arcm-items-center arcm-inline-flex arcm-cursor-pointer after:arcm-content-[''] after:arcm-w-5 after:arcm-h-5 after:arcm-border after:arcm-rounded-full after:arcm-border-gray-400 after:arcm-absolute after:arcm-left-6 before:arcm-content-[''] before:arcm-w-3 before:arcm-h-3 before:arcm-rounded-full before:arcm-bg-transparent before:arcm-absolute before:arcm-left-7 arcm-transition-all has-[:checked]:before:arcm-bg-[#3858e9] has-[:checked]:after:arcm-border-[#3858e9] arcm-border-2 arcm-border-[#e3e3e3]"
                  >
                    <input
                      type='radio'
                      id='arcm-json'
                      name='export-format'
                      className='!arcm-hidden'
                      value='json'
                      checked={exportFormat === 'json'}
                      onChange={e => {
                        setExportFormat(e.target.value)
                      }}
                    />
                    <span>{t('json')}</span>
                  </label>
                  <label
                    htmlFor='arcm-xml'
                    className=" arcm-grow arcm-shrink arcm-radio arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-p-5 arcm-pl-[52px] arcm-bg-white arcm-rounded-lg arcm-relative arcm-min-w-[50px] arcm-items-center arcm-inline-flex arcm-cursor-pointer after:arcm-content-[''] after:arcm-w-5 after:arcm-h-5 after:arcm-border after:arcm-rounded-full after:arcm-border-gray-400 after:arcm-absolute after:arcm-left-6 before:arcm-content-[''] before:arcm-w-3 before:arcm-h-3 before:arcm-rounded-full before:arcm-bg-transparent before:arcm-absolute before:arcm-left-7 arcm-transition-all has-[:checked]:before:arcm-bg-[#3858e9] has-[:checked]:after:arcm-border-[#3858e9] arcm-border-2 arcm-border-[#e3e3e3]"
                  >
                    <input
                      type='radio'
                      id='arcm-xml'
                      name='export-format'
                      className='!arcm-hidden'
                      value='xml'
                      checked={exportFormat === 'xml'}
                      onChange={e => {
                        setExportFormat(e.target.value)
                      }}
                    />
                    <span>{t('xml')}</span>
                  </label>
                  {isPro ? (
                    <label
                      htmlFor='arcm-csv'
                      className=" arcm-grow arcm-shrink arcm-radio arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-p-5 arcm-pl-[52px] arcm-bg-white arcm-rounded-lg arcm-relative arcm-min-w-[50px] arcm-items-center arcm-inline-flex arcm-cursor-pointer after:arcm-content-[''] after:arcm-w-5 after:arcm-h-5 after:arcm-border after:arcm-rounded-full after:arcm-border-gray-400 after:arcm-absolute after:arcm-left-6 before:arcm-content-[''] before:arcm-w-3 before:arcm-h-3 before:arcm-rounded-full before:arcm-bg-transparent before:arcm-absolute before:arcm-left-7 arcm-transition-all has-[:checked]:before:arcm-bg-[#3858e9] has-[:checked]:after:arcm-border-[#3858e9] arcm-border-2 arcm-border-[#e3e3e3]"
                    >
                      <input
                        type='radio'
                        id='arcm-csv'
                        name='export-format'
                        className='!arcm-hidden'
                        value='csv'
                        checked={exportFormat === 'csv'}
                        onChange={e => {
                          setExportFormat(e.target.value)
                        }}
                      />
                      <span>{t('csv')}</span>
                    </label>
                  ) : (
                    <div
                      className='arcm-grow btn-prolock arcm-shrink arcm-overflow-hidden arcm-radio arcm-text-gray-900 arcm-text-sm arcm-font-medium arcm-p-5 arcm-pl-[30px] arcm-bg-white arcm-rounded-lg arcm-relative arcm-min-w-[120px] arcm-min-h-[64px] arcm-items-center arcm-inline-flex arcm-cursor-pointer arcm-border-2 arcm-border-[#e3e3e3] arcm-opacity-60 pointer-events-auto'
                      onClick={flashDoor}
                    >
                      <input
                        type='radio'
                        id='arcm-csv'
                        name='export-format'
                        className='!arcm-hidden'
                        value='csv'
                        disabled
                        tabIndex={-1}
                        style={{ pointerEvents: 'none' }}
                      />
                      <span className='arcm-absolute arcm-left-[25px] arcm-top-[50%] arcm-translate-y-[-50%]'>
                        {t('csv')}
                      </span>
                      <button className='arcm-absolute arcm-right-[25px] arcm-top-[50%] arcm-translate-y-[-50%] arcm-px-1.5  arcm-inline-flex arcm-items-center arcm-pt-[3px] arcm-pb-[4px] arcm-bg-[#FFE9FE] arcm-rounded-[26px] arcm-text-[#4d1c4b] arcm-text-sm arcm-font-normal '>
                        <span className='icon-wrap'>
                          <svg
                            xmlns='http://www.w3.org/2000/svg'
                            width='13'
                            height='11'
                            viewBox='0 0 13 11'
                            fill='none'
                          >
                            <path
                              d='M0.806113 7.65309C0.542977 5.94268 0.279841 4.23232 0.0167049 2.52191C-0.0416496 2.14276 0.389758 1.88417 0.696628 2.11434C1.51645 2.7292 2.33622 3.34402 3.15604 3.95889C3.42597 4.16133 3.81053 4.09545 3.99766 3.81471L6.04517 0.743421C6.26154 0.41886 6.73842 0.41886 6.95479 0.743421L9.0023 3.81471C9.18944 4.09545 9.574 4.16129 9.84392 3.95889C10.6637 3.34402 11.4835 2.7292 12.3033 2.11434C12.6102 1.88417 13.0416 2.14276 12.9833 2.52191C12.7202 4.23232 12.457 5.94268 12.1939 7.65309H0.806113Z'
                              fill='#F748F0'
                            />
                            <path
                              d='M11.6001 10.5H1.39974C1.07185 10.5 0.80603 10.2342 0.80603 9.90627V8.60205H12.1938V9.90627C12.1938 10.2342 11.9279 10.5 11.6001 10.5Z'
                              fill='#F748F0'
                            />
                          </svg>
                        </span>
                        <span className='text'>{t('button.upgrade')}</span>
                      </button>
                    </div>
                  )}
                </div>
              </div>
              <div className='arcm-w-full arcm-text-center arcm-mb-3'>
                <button
                  onClick={exportOrder}
                  className='arcm-text-white arcm-text-xs sm:arcm-text-sm arcm-font-semibold arcm-px-4 arcm-py-3 arcm-border arcm-border-[#3858e9] arcm-rounded-lg arcm-justify-center arcm-items-center arcm-gap-2 arcm-inline-flex arcm-transition-all arcm-group arcm-bg-[#3858e9] hover:arcm-bg-white hover:arcm-text-[#3858e9]'
                >
                  <span className='icon'>
                    <svg
                      xmlns='http://www.w3.org/2000/svg'
                      width='18'
                      height='18'
                      viewBox='0 0 18 18'
                      fill='none'
                    >
                      <path
                        className='arcm-transition-all group-hover:arcm-stroke-[#3858E9]'
                        d='M1.5 12.75V14.625C1.5 15.6605 2.33947 16.5 3.375 16.5H14.625C15.6605 16.5 16.5 15.6605 16.5 14.625V12.75M12.75 9L9 12.75M9 12.75L5.25 9M9 12.75V1.5'
                        stroke='#ffffff'
                        strokeWidth='1.5'
                        strokeLinecap='round'
                        strokeLinejoin='round'
                      />
                    </svg>
                  </span>
                  <span>{t('export_now')}</span>
                </button>
              </div>
            </div>
          )
        }}
      </Modal>

      {/* Cancel exporting modal */}
      <Modal
        openModal={isOpenExportCancelModal}
        toggleModal={handleExportCancelModal}
        outerClick={false}
      >
        {{
          header: (
            <h2 className='arcm-text-2xl arcm-font-bold arcm-text-black arcm-text-left arcm-mb-4'>
              {t('cancel_export_title')}
            </h2>
          ),
          body: (
            <div className='arcm-text-left arcm-mb-6'>
              <p className='arcm-text-gray-900 arcm-text-base arcm-font-semibold'>
                {t('cancel_export_confirm')}
              </p>
              <div className='btn-box arcm-flex arcm-flex-wrap arcm-gap-4 arcm-mt-6'>
                <button
                  onClick={handelCancelExporting}
                  disabled={cancelExportBtnLoading}
                  className='arcm-flex-grow arcm-text-white arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-red-500 arcm-transition-all hover:arcm-bg-red-400 disabled:arcm-opacity-50 disabled:arcm-cursor-not-allowed arcm-flex arcm-items-center arcm-justify-center arcm-gap-2'
                >
                  {cancelExportBtnLoading ? (
                    <>
                      <span className='icon'>{arcmIcons.spinning}</span>
                      {t('cancelling')}
                    </>
                  ) : (
                    t('cancel_exporting')
                  )}
                </button>
                <button
                  onClick={handleExportCancelModal}
                  disabled={cancelExportBtnLoading}
                  className='arcm-flex-grow arcm-text-gray-900 arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-slate-100 arcm-transition-all hover:arcm-bg-slate-300'
                >
                  {t('close')}
                </button>
              </div>
            </div>
          )
        }}
      </Modal>

      {/* Start Unarchive Cancel Modal */}
      <Modal
        openModal={isUnarchiveCancelModal}
        toggleModal={handleUnarchiveCancelModal}
        isCrossBtnDisabled={false}
        outerClick={!cancelUnarchiveBtnLoading}
      >
        {{
          header: isUnarchiveCancel ? (
            <h2 className='arcm-text-2xl arcm-font-bold arcm-text-red-500 arcm-mb-4'>
              {t('unarchiving_cancelled')}
            </h2>
          ) : (
            <h5 className='arcm-text-gray-800 arcm-text-lg sm:arcm-text-xl arcm-font-bold'>
              {t('cancel_unarchive_confirm')}
            </h5>
          ),
          body: isUnarchiveCancel ? (
            <>
              <p className='arcm-text-lg arcm-mb-3'>
                {t('unarchive_complete_message')
                  .replace('%1$s', unArchvedOrder)
                  .replace('%2$s', totalUnArchvedOrder)}
              </p>

              <p className='arcm-text-gray-700 arcm-mb-6'>
                {t('unarchive_restore_notice')}
              </p>

              <div className='arcm-flex arcm-justify-center arcm-mt-6'>
                <button
                  onClick={handleUnarchiveCancelModal}
                  className='arcm-min-w-[120px] arcm-bg-[#F3F4F6] arcm-text-gray-900 arcm-font-medium arcm-py-2.5 arcm-px-4 arcm-rounded-lg hover:arcm-bg-gray-200 arcm-transition-colors'
                >
                  {t('close')}
                </button>
              </div>
            </>
          ) : (
            <div className='arcm-text-left arcm-mb-6'>
              <p className='arcm-text-gray-900 arcm-text-sm arcm-mb-7 arcm-font-normal'>
                {t('cancel_unarchive_message')}
              </p>
              <p className='arcm-text-gray-900 arcm-text-sm arcm-mb-7 arcm-font-normal'>
                {t('unarchive_cancel_notice')}
              </p>
              <div className='btn-box arcm-flex arcm-flex-wrap arcm-gap-4 arcm-mt-6'>
                <button
                  onClick={handelCancelUnarchiving}
                  disabled={cancelUnarchiveBtnLoading}
                  className='arcm-flex-grow arcm-text-white arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-red-500 arcm-transition-all hover:arcm-bg-red-400 disabled:arcm-opacity-50 disabled:arcm-cursor-not-allowed arcm-flex arcm-items-center arcm-justify-center arcm-gap-2'
                >
                  {cancelUnarchiveBtnLoading ? (
                    <>
                      <span className='icon'>{arcmIcons.spinning}</span>
                      {t('cancelling')}
                    </>
                  ) : (
                    t('cancel_unarchiving')
                  )}
                </button>
                <button
                  onClick={handleUnarchiveCancelModal}
                  disabled={cancelUnarchiveBtnLoading}
                  className='arcm-flex-grow arcm-text-gray-900 arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-slate-100 arcm-transition-all hover:arcm-bg-slate-300'
                >
                  {t('close')}
                </button>
              </div>
            </div>
          )
        }}
      </Modal>

      {/* Start Unarchive Modal */}
      <Modal
        openModal={isStartUnarchiveModal}
        toggleModal={handleStartUnarchiveModal}
        outerClick={false}
      >
        {{
          header: (
            <h2 className='arcm-text-lg arcm-font-bold arcm-text-black arcm-text-left arcm-mb-4'>
              {t('unarchive_all_confirm')}
            </h2>
          ),
          body: (
            <div className='arcm-text-left arcm-mb-6'>
              <p className='arcm-text-gray-900 arcm-text-sm arcm-font-semibold'>
                {t('unarchive_time_notice')}
              </p>
              <div className='btn-box arcm-flex arcm-flex-wrap arcm-gap-4 arcm-mt-6'>
                <button
                  onClick={proceedBgUnArchiving}
                  className='arcm-flex-grow arcm-text-white arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-[#3858E9] arcm-transition-all hover:arcm-bg-[#3858E9] arcm-flex arcm-items-center arcm-justify-center arcm-gap-2'
                >
                  {t('proceed_to_unarchiving')}
                </button>
                <button
                  onClick={handleStartUnarchiveModal}
                  className='arcm-flex-grow arcm-text-gray-900 arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-slate-100 arcm-transition-all hover:arcm-bg-slate-300'
                >
                  {t('close')}
                </button>
              </div>
            </div>
          )
        }}
      </Modal>
      
      {/* Empty Order Modal */}
      <Modal
        openModal={isEmptyOrderModal}
        toggleModal={handleIsEmptyOrderModal}
        outerClick={false}
      >
        {{
          body: (
            <div className='arcm-text-center arcm-my-6'>
              <>
                <div className='icon arcm-inline-flex arcm-mb-6'>
                  <svg
                    xmlns='http://www.w3.org/2000/svg'
                    x='0px'
                    y='0px'
                    width='100'
                    height='100'
                    viewBox='0 0 48 48'
                  >
                    <path
                      fill='#f44336'
                      d='M44,24c0,11.045-8.955,20-20,20S4,35.045,4,24S12.955,4,24,4S44,12.955,44,24z'
                    ></path>
                    <path
                      fill='#fff'
                      d='M29.656,15.516l2.828,2.828l-14.14,14.14l-2.828-2.828L29.656,15.516z'
                    ></path>
                    <path
                      fill='#fff'
                      d='M32.484,29.656l-2.828,2.828l-14.14-14.14l2.828-2.828L32.484,29.656z'
                    ></path>
                  </svg>
                </div>
                <h5 className='arcm-text-gray-900 arcm-text-base arcm-font-semibold arcm-mb-1.5'>
                  {emptyOrderTitle}
                </h5>
                <button
                  onClick={handleIsEmptyOrderModal}
                  className='arcm-text-white arcm-text-sm arcm-font-semibold arcm-px-4 arcm-py-3 arcm-min-w-[120px] arcm-bg-[#3858e9] arcm-rounded-lg arcm-justify-center arcm-items-center arcm-gap-2 arcm-inline-flex arcm-transition-all hover:arcm-bg-blue-700'
                >
                  <span>Ok</span>
                </button>
              </>
            </div>
          )
        }}
      </Modal>

      {/* Delete Confirmation Modal */}
      <Modal
        openModal={isOpenDeleteConfirmModal}
        toggleModal={() => setIsOpenDeleteConfirmModal(false)}
        outerClick={!deleteLoading}
      >
        {{
          header: (
            <h5 className='arcm-text-gray-800 arcm-text-lg sm:arcm-text-xl arcm-font-bold'>
              {t('confirm_permanent_deletion')}
            </h5>
          ),
          body: (
            <div className='arcm-text-left arcm-mb-6'>
              <p className='arcm-text-gray-900 arcm-text-sm arcm-mb-7 arcm-font-normal'>
                {t('permanent_delete_warning').replace(
                  '%s',
                  selectedOrders.length
                )}
              </p>
              <div className='btn-box arcm-flex arcm-flex-wrap arcm-gap-4 arcm-mt-6'>
                <button
                  onClick={handlePermanentDelete}
                  disabled={deleteLoading}
                  className='arcm-flex-grow arcm-text-white arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-red-500 arcm-transition-all hover:arcm-bg-red-400 disabled:arcm-opacity-50 disabled:arcm-cursor-not-allowed arcm-flex arcm-items-center arcm-justify-center arcm-gap-2'
                >
                  {deleteLoading ? (
                    <>
                      <span className='icon'>{arcmIcons.spinning}</span>
                      {t('deleting')}
                    </>
                  ) : (
                    t('permanently_delete')
                  )}
                </button>
                <button
                  onClick={() => setIsOpenDeleteConfirmModal(false)}
                  disabled={deleteLoading}
                  className='arcm-flex-grow arcm-text-gray-900 arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-slate-100 arcm-transition-all hover:arcm-bg-slate-300'
                >
                  {t('close')}
                </button>
              </div>
            </div>
          )
        }}
      </Modal>

      {/* Sync Archive Data Confirmation Modal */}
      <Modal
        openModal={isSyncModalOpen}
        toggleModal={handleSyncModal}
        outerClick={!syncLoading}
      >
        {{
          header: (
            <h2 className='arcm-text-base arcm-font-bold arcm-text-black arcm-text-left arcm-mb-4 arcm-pr-8'>
              {t('update_archived_orders_data_from_google_drive') ||
                'Update archived orders data from Google Drive?'}
            </h2>
          ),
          body: (
            <div className='arcm-text-left arcm-mb-6'>
              <p className='arcm-text-gray-900 arcm-text-sm arcm-mb-7 arcm-font-normal'>
                {t('sync_archive_data_description') ||
                  'The archived orders data will be updated with the latest archive data from Google Drive. Do you want to proceed?'}
              </p>
              <div className='btn-box arcm-flex arcm-flex-wrap arcm-gap-4 arcm-mt-6'>
                <button
                  onClick={handleSyncArchiveData}
                  disabled={syncLoading}
                  className='arcm-flex-grow arcm-text-white arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-[#3858E9] arcm-transition-all hover:arcm-bg-[#2947D1] disabled:arcm-opacity-50 disabled:arcm-cursor-not-allowed arcm-flex arcm-items-center arcm-justify-center arcm-gap-2'
                >
                  {syncLoading ? (
                    <>
                      <span className='icon'>{arcmIcons.spinning}</span>
                      {t('syncing') || 'Syncing...'}
                    </>
                  ) : (
                    t('confirm') || 'Confirm'
                  )}
                </button>
                <button
                  onClick={handleSyncModal}
                  disabled={syncLoading}
                  className='arcm-flex-grow arcm-text-gray-900 arcm-text-sm arcm-font-semibold arcm-min-w-[120px] arcm-px-4 arcm-py-2.5 arcm-rounded-lg arcm-bg-slate-100 arcm-transition-all hover:arcm-bg-slate-300 disabled:arcm-opacity-50'
                >
                  {t('cancel') || 'Cancel'}
                </button>
              </div>
            </div>
          )
        }}
      </Modal>
    </>
  )
}

export default ArchivedOrderModals
