mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-11-04 23:10:13 +01:00
feat: automatically detect hour format
This commit is contained in:
parent
13d6f05b98
commit
4e3f6be8e3
@ -1,4 +1,3 @@
|
|||||||
SHOW_HOME_PAGE=true
|
SHOW_HOME_PAGE=true
|
||||||
ALLOW_REGISTRATION=true
|
ALLOW_REGISTRATION=true
|
||||||
MAX_FILE_SIZE=1000000000
|
MAX_FILE_SIZE=1000000000
|
||||||
TWELVE_HOUR_TIME=false
|
|
||||||
|
@ -6,7 +6,6 @@ const nextConfig = {
|
|||||||
SHOW_HOME_PAGE: process.env.SHOW_HOME_PAGE,
|
SHOW_HOME_PAGE: process.env.SHOW_HOME_PAGE,
|
||||||
MAX_FILE_SIZE: process.env.MAX_FILE_SIZE,
|
MAX_FILE_SIZE: process.env.MAX_FILE_SIZE,
|
||||||
BACKEND_URL: process.env.BACKEND_URL,
|
BACKEND_URL: process.env.BACKEND_URL,
|
||||||
TWELVE_HOUR_TIME: process.env.TWELVE_HOUR_TIME
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
Accordion,
|
Accordion,
|
||||||
Button,
|
Button,
|
||||||
Col,
|
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
Col,
|
||||||
Grid,
|
Grid,
|
||||||
NumberInput,
|
NumberInput,
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
@ -13,13 +13,10 @@ import {
|
|||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useForm, yupResolver } from "@mantine/form";
|
import { useForm, yupResolver } from "@mantine/form";
|
||||||
import { useModals } from "@mantine/modals";
|
import { useModals } from "@mantine/modals";
|
||||||
|
import moment from "moment";
|
||||||
import * as yup from "yup";
|
import * as yup from "yup";
|
||||||
import shareService from "../../services/share.service";
|
import shareService from "../../services/share.service";
|
||||||
import { ShareSecurity } from "../../types/share.type";
|
import { ShareSecurity } from "../../types/share.type";
|
||||||
import moment from "moment";
|
|
||||||
import getConfig from "next/config";
|
|
||||||
|
|
||||||
const { publicRuntimeConfig } = getConfig();
|
|
||||||
|
|
||||||
const PreviewExpiration = ({ form }: { form: any }) => {
|
const PreviewExpiration = ({ form }: { form: any }) => {
|
||||||
const value = form.values.never_expires
|
const value = form.values.never_expires
|
||||||
@ -34,14 +31,7 @@ const PreviewExpiration = ({ form }: { form: any }) => {
|
|||||||
)
|
)
|
||||||
.toDate();
|
.toDate();
|
||||||
|
|
||||||
if (publicRuntimeConfig.TWELVE_HOUR_TIME === "true")
|
return `This share will expire on ${moment(expirationDate).format("LLL")}`;
|
||||||
return `This share will expire on ${moment(expirationDate).format(
|
|
||||||
"MMMM Do YYYY, h:mm a"
|
|
||||||
)}`;
|
|
||||||
else
|
|
||||||
return `This share will expire on ${moment(expirationDate).format(
|
|
||||||
"MMMM DD YYYY, HH:mm"
|
|
||||||
)}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const CreateUploadModalBody = ({
|
const CreateUploadModalBody = ({
|
||||||
|
@ -62,11 +62,9 @@ const Body = ({ share }: { share: Share }) => {
|
|||||||
{/* If our share.expiration is timestamp 0, show a different message */}
|
{/* If our share.expiration is timestamp 0, show a different message */}
|
||||||
{moment(share.expiration).unix() === 0
|
{moment(share.expiration).unix() === 0
|
||||||
? "This share will never expire."
|
? "This share will never expire."
|
||||||
: `This share will expire on ${
|
: `This share will expire on ${moment(share.expiration).format(
|
||||||
publicRuntimeConfig.TWELVE_HOUR_TIME === "true"
|
"LLL"
|
||||||
? moment(share.expiration).format("MMMM Do YYYY, h:mm a")
|
)}`}
|
||||||
: moment(share.expiration).format("MMMM DD YYYY, HH:mm")
|
|
||||||
}`}
|
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -14,6 +14,7 @@ import { useClipboard } from "@mantine/hooks";
|
|||||||
import { useModals } from "@mantine/modals";
|
import { useModals } from "@mantine/modals";
|
||||||
import { NextLink } from "@mantine/next";
|
import { NextLink } from "@mantine/next";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import getConfig from "next/config";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { TbLink, TbTrash } from "react-icons/tb";
|
import { TbLink, TbTrash } from "react-icons/tb";
|
||||||
@ -22,7 +23,6 @@ import useUser from "../../hooks/user.hook";
|
|||||||
import shareService from "../../services/share.service";
|
import shareService from "../../services/share.service";
|
||||||
import { MyShare } from "../../types/share.type";
|
import { MyShare } from "../../types/share.type";
|
||||||
import toast from "../../utils/toast.util";
|
import toast from "../../utils/toast.util";
|
||||||
import getConfig from "next/config";
|
|
||||||
|
|
||||||
const { publicRuntimeConfig } = getConfig();
|
const { publicRuntimeConfig } = getConfig();
|
||||||
|
|
||||||
@ -77,9 +77,7 @@ const MyShares = () => {
|
|||||||
<td>
|
<td>
|
||||||
{moment(share.expiration).unix() === 0
|
{moment(share.expiration).unix() === 0
|
||||||
? "Never"
|
? "Never"
|
||||||
: publicRuntimeConfig.TWELVE_HOUR_TIME === "true"
|
: moment(share.expiration).format("LLL")}
|
||||||
? moment(share.expiration).format("MMMM Do YYYY, h:mm a")
|
|
||||||
: moment(share.expiration).format("MMMM DD YYYY, HH:mm")}
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
|
Loading…
Reference in New Issue
Block a user