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