improvement: added validation for the expired date

This commit is contained in:
srinivaspendem 2023-08-11 21:24:28 +05:30
parent 664820af59
commit 250148c991
9 changed files with 32 additions and 18 deletions

View File

@ -731,7 +731,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
</div>
</Command.Item>
<Command.Item
onSelect={() => redirect(`/${workspaceSlug}/settings/import`)}
onSelect={() => redirect(`/${workspaceSlug}/settings/imports`)}
className="focus:outline-none"
>
<div className="flex items-center gap-2 text-custom-text-200">
@ -740,7 +740,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
</div>
</Command.Item>
<Command.Item
onSelect={() => redirect(`/${workspaceSlug}/settings/export`)}
onSelect={() => redirect(`/${workspaceSlug}/settings/exports`)}
className="focus:outline-none"
>
<div className="flex items-center gap-2 text-custom-text-200">

View File

@ -63,7 +63,7 @@ export const Exporter: React.FC<Props> = ({
await CSVIntegrationService.exportCSVService(workspaceSlug as string, payload, user)
.then(() => {
mutateServices();
router.push(`/${workspaceSlug}/settings/export`);
router.push(`/${workspaceSlug}/settings/exports`);
setExportLoading(false);
setToastAlert({
type: "success",

View File

@ -41,7 +41,7 @@ const IntegrationGuide = () => {
);
const handleCsvClose = () => {
router.replace(`/plane/settings/export`);
router.replace(`/plane/settings/exports`);
};
return (

View File

@ -16,6 +16,14 @@ type Props = {
export const SingleExport: React.FC<Props> = ({ service, refreshing }) => {
const provider = service.provider;
const [isLoading, setIsLoading] = React.useState(false);
const checkExpiry = (inputDateString: string) => {
const currentDate = new Date();
const expiryDate = new Date(inputDateString);
expiryDate.setDate(expiryDate.getDate() + 7);
return expiryDate > currentDate;
};
return (
<div className="flex items-center justify-between gap-2 py-3">
<div>
@ -53,14 +61,20 @@ export const SingleExport: React.FC<Props> = ({ service, refreshing }) => {
<span>Exported by {service?.initiated_by_detail?.display_name}</span>
</div>
</div>
{service.status == "completed" && (
<div>
<Link href={service?.url}>
<PrimaryButton className="w-full text-center">
{isLoading ? "Downloading..." : "Download"}
</PrimaryButton>
</Link>
</div>
{checkExpiry(service.created_at) ? (
<>
{service.status == "completed" && (
<div>
<Link href={service?.url}>
<PrimaryButton className="w-full text-center">
{isLoading ? "Downloading..." : "Download"}
</PrimaryButton>
</Link>
</div>
)}
</>
) : (
<div className="text-xs text-red-500">Expired</div>
)}
</div>
);

View File

@ -163,7 +163,7 @@ export const GithubImporterRoot: React.FC<Props> = ({ user }) => {
await GithubIntegrationService.createGithubServiceImport(workspaceSlug as string, payload, user)
.then(() => {
router.push(`/${workspaceSlug}/settings/import`);
router.push(`/${workspaceSlug}/settings/imports`);
mutate(IMPORTER_SERVICES_LIST(workspaceSlug as string));
})
.catch(() =>
@ -178,7 +178,7 @@ export const GithubImporterRoot: React.FC<Props> = ({ user }) => {
return (
<form onSubmit={handleSubmit(createGithubImporterService)}>
<div className="space-y-2">
<Link href={`/${workspaceSlug}/settings/import`}>
<Link href={`/${workspaceSlug}/settings/imports`}>
<div className="inline-flex cursor-pointer items-center gap-2 text-sm font-medium text-custom-text-200 hover:text-custom-text-100">
<ArrowLeftIcon className="h-3 w-3" />
<div>Cancel import & go back</div>

View File

@ -92,7 +92,7 @@ export const JiraImporterRoot: React.FC<Props> = ({ user }) => {
.createJiraImporter(workspaceSlug.toString(), data, user)
.then(() => {
mutate(IMPORTER_SERVICES_LIST(workspaceSlug.toString()));
router.push(`/${workspaceSlug}/settings/import`);
router.push(`/${workspaceSlug}/settings/imports`);
})
.catch((err) => {
console.log(err);
@ -109,7 +109,7 @@ export const JiraImporterRoot: React.FC<Props> = ({ user }) => {
return (
<div className="flex h-full flex-col space-y-2">
<Link href={`/${workspaceSlug}/settings/import`}>
<Link href={`/${workspaceSlug}/settings/imports`}>
<div className="inline-flex cursor-pointer items-center gap-2 text-sm font-medium text-custom-text-200 hover:text-custom-text-100">
<div>
<ArrowLeftIcon className="h-3 w-3" />

View File

@ -31,11 +31,11 @@ const SettingsNavbar: React.FC<Props> = ({ profilePage = false }) => {
},
{
label: "Imports",
href: `/${workspaceSlug}/settings/import`,
href: `/${workspaceSlug}/settings/imports`,
},
{
label: "Exports",
href: `/${workspaceSlug}/settings/export`,
href: `/${workspaceSlug}/settings/exports`,
},
];