feat: reverse shares (#86)
* add first concept * add reverse share funcionality to frontend * allow creator to limit share expiration * moved reverse share in seperate module * add table to manage reverse shares * delete complete share if reverse share was deleted * optimize function names * add db migration * enable reverse share email notifications * fix config variable descriptions * fix migration for new installations
This commit is contained in:
26
frontend/src/utils/date.util.ts
Normal file
26
frontend/src/utils/date.util.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import moment from "moment";
|
||||
|
||||
export const getExpirationPreview = (
|
||||
name: string,
|
||||
form: {
|
||||
values: {
|
||||
never_expires?: boolean;
|
||||
expiration_num: number;
|
||||
expiration_unit: string;
|
||||
};
|
||||
}
|
||||
) => {
|
||||
const value = form.values.never_expires
|
||||
? "never"
|
||||
: form.values.expiration_num + form.values.expiration_unit;
|
||||
if (value === "never") return `This ${name} will never expire.`;
|
||||
|
||||
const expirationDate = moment()
|
||||
.add(
|
||||
value.split("-")[0],
|
||||
value.split("-")[1] as moment.unitOfTime.DurationConstructor
|
||||
)
|
||||
.toDate();
|
||||
|
||||
return `This ${name} will expire on ${moment(expirationDate).format("LLL")}`;
|
||||
};
|
||||
Reference in New Issue
Block a user