Skip to content

Commit

Permalink
Merge pull request #119 from sqrl-planner/develop
Browse files Browse the repository at this point in the history
Bump version
  • Loading branch information
eamonma authored Jul 22, 2022
2 parents 550bea0 + 7445429 commit 4e490de
Show file tree
Hide file tree
Showing 27 changed files with 321 additions and 205 deletions.
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NEXT_PUBLIC_API_URI=http://localhost:8000/graphql
NEXT_PUBLIC_HEAP_ID=0000000000
GITHUB_API_KEY="SAMPLE_KEY"
SQRLDAY_API_KEY=0000000000

13 changes: 3 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"extends": [
"next",
"prettier"
],
"ignorePatterns": [
"*.json"
],
"plugins": [
"unused-imports"
],
"extends": ["next", "prettier"],
"ignorePatterns": ["*.json"],
"plugins": ["unused-imports"],
"rules": {
"no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
Expand Down
24 changes: 13 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
7 changes: 3 additions & 4 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const path = require('path')
const path = require("path")

const buildEslintCommand = (filenames) =>
`next lint --fix --file ${filenames
.map((f) => path.relative(process.cwd(), f))
.join(' --file ')}`
.join(" --file ")}`

module.exports = {
'*.{js,jsx,ts,tsx}': [buildEslintCommand],
"*.{js,jsx,ts,tsx}": [buildEslintCommand],
}

67 changes: 38 additions & 29 deletions components/AboutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const AboutModal = ({ isOpen, onClose }: props) => {
}>({
gator: new Date(),
client: new Date(),
server: new Date()
server: new Date(),
})

const [latestVersion, setLatestVersion] = useState<{
Expand All @@ -104,25 +104,25 @@ const AboutModal = ({ isOpen, onClose }: props) => {
await fetch("/api/github/contributors?repositoryName=gator")
).json()) as unknown as Array<any>

const clientLastUpdated = await ((await fetch(
"/api/github/lastUpdated?repositoryName=sqrl-client"
))).json() as string
const serverLastUpdated = await (await fetch((
"/api/github/lastUpdated?repositoryName=sqrl-server"
))).json() as string
const gatorLastUpdated = await (await fetch((
"/api/github/lastUpdated?repositoryName=gator"
))).json() as string
const clientLastUpdated = (await (
await fetch("/api/github/lastUpdated?repositoryName=sqrl-client")
).json()) as string
const serverLastUpdated = (await (
await fetch("/api/github/lastUpdated?repositoryName=sqrl-server")
).json()) as string
const gatorLastUpdated = (await (
await fetch("/api/github/lastUpdated?repositoryName=gator")
).json()) as string

const clientLatestVersion = await (await fetch((
"/api/github/latestVersion?repositoryName=sqrl-client"
))).text() as string
const serverLatestVersion = await (await fetch((
"/api/github/latestVersion?repositoryName=sqrl-server"
))).text() as string
const gatorLatestVersion = await (await fetch((
"/api/github/latestVersion?repositoryName=gator"
))).text() as string
const clientLatestVersion = (await (
await fetch("/api/github/latestVersion?repositoryName=sqrl-client")
).text()) as string
const serverLatestVersion = (await (
await fetch("/api/github/latestVersion?repositoryName=sqrl-server")
).text()) as string
const gatorLatestVersion = (await (
await fetch("/api/github/latestVersion?repositoryName=gator")
).text()) as string

setContributors({
gator: gatorContributors,
Expand Down Expand Up @@ -172,9 +172,12 @@ const AboutModal = ({ isOpen, onClose }: props) => {
bg={useColorModeValue("blue.50", "blue.800")}
href="https://github.com/sqrl-planner/sqrl-client"
>
<Icon as={FaGithub} /> sqrl-client: {latestVersion.client} <ExternalLinkIcon />
<Icon as={FaGithub} /> sqrl-client: {latestVersion.client}{" "}
<ExternalLinkIcon />
</Link>
<Box opacity={0.6} fontSize="sm" mb={2}>{t("last-updated")} {lastUpdated.client.toLocaleDateString()}.</Box>
<Box opacity={0.6} fontSize="sm" mb={2}>
{t("last-updated")} {lastUpdated.client.toLocaleDateString()}.
</Box>
<Box opacity={0.8}>{t("sqrl-client-description")}</Box>

<Heading
Expand Down Expand Up @@ -221,10 +224,13 @@ const AboutModal = ({ isOpen, onClose }: props) => {
bg={useColorModeValue("blue.50", "blue.800")}
href="https://github.com/sqrl-planner/sqrl-server"
>
<Icon as={FaGithub} /> sqrl-server: {latestVersion.server} <ExternalLinkIcon />
<Icon as={FaGithub} /> sqrl-server: {latestVersion.server}{" "}
<ExternalLinkIcon />
</Link>

<Box opacity={0.6} fontSize="sm" mb={2}>{t("last-updated")} {lastUpdated.server.toLocaleDateString()}.</Box>
<Box opacity={0.6} fontSize="sm" mb={2}>
{t("last-updated")} {lastUpdated.server.toLocaleDateString()}.
</Box>
<Box opacity={0.8}>{t("sqrl-server-description")}</Box>

<Heading
Expand Down Expand Up @@ -271,9 +277,12 @@ const AboutModal = ({ isOpen, onClose }: props) => {
bg={useColorModeValue("blue.50", "blue.800")}
href="https://github.com/sqrl-planner/gator"
>
<Icon as={FaGithub} /> gator: {latestVersion.gator} <ExternalLinkIcon />
<Icon as={FaGithub} /> gator: {latestVersion.gator}{" "}
<ExternalLinkIcon />
</Link>
<Box opacity={0.6} fontSize="sm" mb={2}>{t("last-updated")} {lastUpdated.gator.toLocaleDateString()}.</Box>
<Box opacity={0.6} fontSize="sm" mb={2}>
{t("last-updated")} {lastUpdated.gator.toLocaleDateString()}.
</Box>
<Box opacity={0.8}>{t("gator-description")}</Box>
<Heading
mb={2}
Expand All @@ -295,10 +304,10 @@ const AboutModal = ({ isOpen, onClose }: props) => {
>
{contributors?.gator &&
contributors?.gator.map((contributor) => (
<Contributor
contributor={contributor}
key={contributor.id}
/>
<Contributor
contributor={contributor}
key={contributor.id}
/>
))}
</Grid>
</Flex>
Expand Down
4 changes: 3 additions & 1 deletion components/DisclaimerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const DisclaimerModal = (props: {
}
pb={4}
>
{t("checklist-one-acorn")} <sup>1</sup>, {t("checklist-one-timetable")}<sup>2</sup>, {t("checklist-one-calendar")}
{t("checklist-one-acorn")} <sup>1</sup>,{" "}
{t("checklist-one-timetable")}
<sup>2</sup>, {t("checklist-one-calendar")}
<sup>3</sup> {t("checklist-one-rest")}
</Checkbox>
<Checkbox
Expand Down
7 changes: 1 addition & 6 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Box,
chakra,
Heading,
useColorModeValue,
} from "@chakra-ui/react"
import { Box, chakra, Heading, useColorModeValue } from "@chakra-ui/react"
import Link from "next/link"
import { AnimatePresence, motion } from "framer-motion"
import React from "react"
Expand Down
109 changes: 109 additions & 0 deletions components/ShareLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import {
Text,
FormControl,
Flex,
Icon,
Input,
FormHelperText,
Button,
useClipboard,
useToast,
Skeleton,
} from "@chakra-ui/react"

import { FaShareSquare } from "react-icons/fa"
import { useRouter } from "next/router"
import { CopyIcon } from "@chakra-ui/icons"
import { useTranslation } from "next-i18next"
import { useEffect, useState } from "react"
import useSWR from "swr"
import fetcher from "../src/utils/fetcher"
import getSharePrefix from "../src/utils/getSharePrefix"

const useShortLink = (url: string) => {
const { data, error } = useSWR(`/api/shorten?url=${url}`, fetcher)

return {
data,
isLoading: !error && !data,
isError: error,
}
}

const ShareLink = () => {
const router = useRouter()

const id = router.query.id

const sharePrefix = getSharePrefix()
const fullUrl = `${sharePrefix}${id}`

const [urlToShare, setUrlToShare] = useState(fullUrl)

const toast = useToast()
const { t } = useTranslation("modal")

const { data: shortLink, isLoading, isError } = useShortLink(fullUrl)

useEffect(() => {
if(shortLink?.shortUrl) setUrlToShare(shortLink.shortUrl)
}, [shortLink])

const { onCopy, hasCopied } = useClipboard(urlToShare)

useEffect(() => {
if (!hasCopied) return

toast({
title: "Copied to clipboard",
status: "success",
duration: 9000,
isClosable: true,
})
}, [toast, hasCopied])

return (
<Flex
width="100%"
alignItems="center"
justifyContent="space-between"
// mb={6}
>
<FormControl as="span">
<Text as="span" display="flex" alignItems="center">
<Icon as={FaShareSquare} mr={2} /> {t("share-read-only")}
</Text>
<Flex my={2} alignItems="center" gap={4} justifyContent="space-between">
{isLoading ? (
<Skeleton alignSelf="stretch" flex="1" />
) : (
<Input
whiteSpace="nowrap"
textOverflow="ellipsis"
overflow="hidden"
fontWeight={500}
value={urlToShare}
flex="1"
onFocus={(e) => e.target.select()}
onChange={() => {}}
/>
)}
<Button
isLoading={isLoading}
loadingText={t("copy-link")}
onClick={onCopy}
colorScheme="blue"
bg="blue.700"
>
<CopyIcon mr={2} /> {t("copy-link")}
</Button>
</Flex>
<FormHelperText fontWeight={400}>
{t("share-read-only-description")}
</FormHelperText>
</FormControl>
</Flex>
)
}

export default ShareLink
Loading

0 comments on commit 4e490de

Please sign in to comment.