Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

1.8 KB
Raw Blame
import React from "react";
import { Paper, Text, Group, Stack } from "@mantine/core";
import { Button } from "@editor/ui/Button";
import { useTranslation } from "react-i18next";
import { useDefaultApp } from "@editor/hooks/useDefaultApp";

export const DefaultAppSettings: React.FC = () => {
  const { t } = useTranslation();
  const { isDefault, isLoading, handleSetDefault } = useDefaultApp();

  return (
    <Paper withBorder p="md" radius="md">
      <Stack gap="md">
        <Group justify="space-between" align="center">
          <div>
            <Text fw={500} size="sm">
              {t("settings.general.defaultPdfEditor", "Default PDF editor")}
            </Text>
            <Text size="xs" c="dimmed" mt={4}>
              {isDefault === true
                ? t(
                    "settings.general.defaultPdfEditorActive",
                    "Stirling PDF is your default PDF editor",
                  )
                : isDefault === false
                  ? t(
                      "settings.general.defaultPdfEditorInactive",
                      "Another application is set as default",
                    )
                  : t(
                      "settings.general.defaultPdfEditorChecking",
                      "Checking...",
                    )}
            </Text>
          </div>
          <Button
            variant={isDefault ? "secondary" : "primary"}
            size="sm"
            onClick={handleSetDefault}
            loading={isLoading}
            disabled={isDefault === true}
          >
            {isDefault
              ? t("settings.general.defaultPdfEditorSet", "Already Default")
              : t("settings.general.setAsDefault", "Set as Default")}
          </Button>
        </Group>
      </Stack>
    </Paper>
  );
};