Skip to content

Commit

Permalink
Revert "feat(proposal): add validation to start time (#3991)" (#4010)
Browse files Browse the repository at this point in the history
This reverts commit abf53c7.
  • Loading branch information
ChaituVR authored Jun 22, 2023
1 parent abf53c7 commit 84bb9b5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
35 changes: 4 additions & 31 deletions src/components/ModalSelectDate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ const { open } = toRefs(props);
const step = ref(0);
const input = ref('');
const time = ref('12:00');
const isTimeValid = computed(() => {
const isTimeEnteringStep = step.value === 1;
if (!isTimeEnteringStep) return true;
if (!input.value) return false;
const startDateString = `${input.value} ${time.value}:59`;
const startTimestamp = new Date(startDateString).getTime();
return startTimestamp >= Date.now();
});
function formatDate(date) {
const output = { h: '12', m: '00', dateString: '' };
Expand All @@ -38,8 +28,7 @@ function handleSubmit() {
if (step.value === 0) return (step.value = 1);
const dateString = `${input.value} ${time.value}:00`;
const timestamp = new Date(dateString).getTime() / 1000;
const now = parseInt((Date.now() / 1e3).toFixed());
emit('input', Math.max(timestamp, now));
emit('input', timestamp);
emit('close');
}
Expand All @@ -50,17 +39,6 @@ watch(open, () => {
time.value = `${h}:${m}`;
input.value = dateString;
});
watch(step, () => {
if (step.value === 0) return;
const timestamp = Math.max(
props.value,
parseInt((Date.now() / 1e3 + 10).toFixed())
);
const { dateString, h, m } = formatDate(timestamp);
time.value = `${h}:${m}`;
input.value = dateString;
});
</script>

<template>
Expand All @@ -78,16 +56,11 @@ watch(step, () => {
<BaseCalendar v-model="input" class="mx-auto mb-2" />
</div>
</div>
<div v-else class="m-4">
<div v-else class="m-4 mx-auto max-w-[140px]">
<input
v-model="time"
type="time"
class="s-input form-input mx-auto max-w-[140px] text-center text-lg"
/>
<TuneErrorInput
v-if="!isTimeValid"
class="mx-auto mt-2 text-center"
:error="$t('create.errorTimeInPast')"
class="s-input form-input text-center text-lg"
/>
</div>
<template #footer>
Expand All @@ -99,7 +72,7 @@ watch(step, () => {
<div class="float-left w-2/4 pl-2">
<BaseButton
type="submit"
:disabled="!isTimeValid"
:disabled="!input"
class="w-full"
primary
@click="handleSubmit"
Expand Down
3 changes: 1 addition & 2 deletions src/locales/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@
"uploadImageExplainer": "Attach images by dragging & dropping, selecting or pasting them.",
"uploading": "Uploading image",
"markdown": "Styling with Markdown is supported",
"errorGettingSnapshot": "We encountered an error while fetching the snapshot block number which is needed to calculate your voting power. Please try again later.",
"errorTimeInPast": "Entered time is in the past. Please select a future time."
"errorGettingSnapshot": "We encountered an error while fetching the snapshot block number which is needed to calculate your voting power. Please try again later."
},
"delegate": {
"header": "Delegate",
Expand Down
3 changes: 1 addition & 2 deletions src/views/SpaceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ function getFormattedForm() {
.map(choice => choice.text)
.filter(choiceText => choiceText.length > 0);
updateTime();
const thisMomentTimestamp = parseInt((Date.now() / 1e3).toFixed());
clonedForm.start = Math.max(thisMomentTimestamp, dateStart.value);
clonedForm.start = dateStart.value;
clonedForm.end = dateEnd.value;
return clonedForm;
}
Expand Down

1 comment on commit 84bb9b5

@vercel
Copy link

@vercel vercel bot commented on 84bb9b5 Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.