Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Afordin/aforshow
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian-Zsiros-Prog committed Jul 7, 2023
2 parents 5ddb1c9 + 6f1ec42 commit 41df9fe
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 40 deletions.
14 changes: 7 additions & 7 deletions src/components/Countdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ import { calculateTimeLeft } from '../utils/calculateTimeLeft'

const CountdownCard = ({ label, time }) => {
return (
<div className='text-gray-400 bg-[#141414] px-6 py-4 flex flex-col rounded-lg border-t-2 border-gray-500'>
<span className='font-extrabold text-3xl sm:text-5xl text-gradient'>
<div className="text-gray-400 bg-[#141414] px-6 py-4 flex flex-col rounded-lg border-t-2 border-gray-500">
<span className="font-extrabold text-3xl sm:text-5xl text-gradient">
{time}{' '}
</span>
<span className='text-[20px]'>{label}</span>
<span className="text-[20px]">{label}</span>
</div>
)
}

const Countdown = () => {
const [timeLeft, setTimeLeft] = useState(calculateTimeLeft())
const Countdown = ({ date }) => {
const [timeLeft, setTimeLeft] = useState(calculateTimeLeft(date))

useEffect(() => {
const timer = setTimeout(() => {
setTimeLeft(calculateTimeLeft())
setTimeLeft(calculateTimeLeft(date))
}, 1000)

return () => clearTimeout(timer)
})

return (
<div className='m-auto h-[100%] flex-wrap justify-center items-center text-center text-lg sm:text-3xl mt-4 flex gap-4 sm:gap-8'>
<div className="m-auto h-[100%] flex-wrap justify-center items-center text-center text-lg sm:text-3xl mt-4 flex gap-4 sm:gap-8">
{timeLeft.map((time, index) => (
<CountdownCard
label={time.label}
Expand Down
5 changes: 4 additions & 1 deletion src/components/DateHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { useMemo } from 'react'
import { getLocalTime } from '../utils/getLocalTime'

export default function DateHeader() {
const { day, monthName, time } = useMemo(() => getLocalTime(), [])
const { day, monthName, time } = useMemo(
() => getLocalTime('2023-07-21T20:00:00+02:00'),
[]
)
return (
<h3 className="text-center text-4xl">
<span className="font-bold text-white">
Expand Down
49 changes: 22 additions & 27 deletions src/components/Ticket/Ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,33 @@ export default function Ticket({}) {

const { data, error } = await supabase.storage
.from('Tickets Images')
.getPublicUrl(
.download(
`Ticket-de-@${userInfo.username_github}.png`
)

if (error) {
console.error(
'Error al verificar la existencia de la imagen:',
error.message
)
} else {
if (data.publicUrl) {
// La imagen no existe, realizar la subida
const response = await fetch(imgData)
const blob = await response.blob()
if (error && error.message === "The resource was not found") {
// La imagen no existe, realizar la subida
const response = await fetch(imgData)
const blob = await response.blob()

const {
data: uploadData,
error: uploadError,
} = await supabase.storage
.from('Tickets Images')
.upload(
`Ticket-de-@${userInfo.username_github}.png`,
blob
)
const {
data: uploadData,
error: uploadError,
} = await supabase.storage
.from('Tickets Images')
.upload(
`Ticket-de-@${userInfo.username_github}.png`,
blob
)

if (uploadError) {
console.error(
'Error al subir la imagen:',
uploadError.message
)
}
} else {
if (uploadError) {
console.error(
'Error al subir la imagen:',
uploadError.message
)
}
} else {
if (data) {
console.log(
'La imagen ya existe en el almacenamiento de Supabase.'
)
Expand Down
5 changes: 4 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ const ogTitle =
id="countdown"
>
<h3 class="text-gray-400 text-2xl">Quedan</h3>
<Countdown client:only="react" />
<Countdown
client:only="react"
date="2023-07-21T20:00:00+02:00"
/>
<h3 class="text-gray-400 text-2xl">
Para el <span class="font-bold">AforShow</span>
</h3>
Expand Down
4 changes: 2 additions & 2 deletions src/utils/calculateTimeLeft.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getLocalTime } from './getLocalTime'

export function calculateTimeLeft() {
const { fulltime } = getLocalTime()
export function calculateTimeLeft(time) {
const { fulltime } = getLocalTime(time)
const difference = new Date(fulltime) - new Date()

let timeLeft = []
Expand Down
4 changes: 2 additions & 2 deletions src/utils/getLocalTime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TimeLocal } from '../types/types'

export function getLocalTime(): TimeLocal {
const date = new Date('2023-07-21T20:00:00+02:00')
export function getLocalTime(time): TimeLocal {
const date = new Date(time)

return {
day: Number.parseInt(
Expand Down

0 comments on commit 41df9fe

Please sign in to comment.