Skip to content

Commit

Permalink
Migrate web & fix moment errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ruilopesm committed Feb 23, 2023
1 parent 82a4118 commit c03a199
Show file tree
Hide file tree
Showing 12 changed files with 5,085 additions and 4,275 deletions.
4 changes: 2 additions & 2 deletions apps/app/components/NinjaForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Typography,
notification,
} from "antd";
import moment from "moment";
import dayjs from "dayjs";
import { CloseOutlined, SaveOutlined } from "@ant-design/icons";
import * as api from "bokkenjs";
import { notifyError, notifyInfo } from "~/components/Notification";
Expand Down Expand Up @@ -191,7 +191,7 @@ export default function NinjaForm({ id }) {
name="ninja[birthday]"
rules={[{ required: true }]}
initialValue={
id && ninja ? moment(ninja.birthday, "YYYY-MM-DD") : null
id && ninja ? dayjs(ninja.birthday, "YYYY-MM-DD") : null
}
>
<DatePicker />
Expand Down
11 changes: 7 additions & 4 deletions apps/app/components/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
notification,
} from "antd";
import { ClockCircleOutlined, UserOutlined } from "@ant-design/icons";
import moment from "moment";
import "moment/locale/pt";
import Badge from "~/components/Badge";
import Belt from "~/components/Belt";
import Document from "~/components/Document";
Expand All @@ -23,6 +21,11 @@ import { notifyError, notifyInfo } from "~/components/Notification";
import styles from "./style.module.css";
import { EUser } from "bokkenjs";

import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
dayjs.extend(relativeTime);
import "dayjs/locale/pt";

import { BsFileEarmarkPersonFill } from "react-icons/bs";

import { getIcon } from "~/lib/utils";
Expand Down Expand Up @@ -97,7 +100,7 @@ function Profile({ id, role }: Props) {
}, [id, role]);

useEffect(() => {
setDate(moment(info.since).format("DD/MM/YYYY"));
setDate(dayjs(info.since).format("DD/MM/YYYY"));
}, [info]);

return (
Expand Down Expand Up @@ -175,7 +178,7 @@ function Profile({ id, role }: Props) {
<Timeline mode="alternate">
<Timeline.Item dot={<ClockCircleOutlined />}>
Registou-se na plataforma{" "}
{moment(info.since).locale("pt").fromNow()}
{dayjs(info.since).locale("pt").fromNow()}
</Timeline.Item>
</Timeline>
</TabPane>
Expand Down
2 changes: 1 addition & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@netlify/plugin-nextjs": "^4.29.2",
"antd": "^5.0.0",
"bokkenjs": "*",
"dayjs": "^1.11.7",
"lodash-es": "^4.17.21",
"moment": "^2.29.4",
"next": "^12.3.4",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
22 changes: 7 additions & 15 deletions apps/app/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,19 @@ function Shuriken({ Component, pageProps }: AppProps) {
};

return (
<ConfigProvider
form={{ validateMessages }}
locale={ptPT}
theme={{
token: {
colorPrimary: "#722ed1",
},
}}
>
<ThemeProvider>
<QueryClientProvider client={queryClient}>
<ThemeProvider>
<QueryClientProvider client={queryClient}>
<ConfigProvider form={{ validateMessages }} locale={ptPT}>
<AuthProvider>
<Head>
<title>CoderDojo Braga</title>
</Head>
<Component {...pageProps} />
<ReactQueryDevtools position="bottom-right" />
</AuthProvider>
</QueryClientProvider>
</ThemeProvider>
</ConfigProvider>
</ConfigProvider>
<ReactQueryDevtools position="bottom-right" />
</QueryClientProvider>
</ThemeProvider>
);
}

Expand Down
4 changes: 2 additions & 2 deletions apps/app/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useEvents } from "~/hooks/events";
import { notifyError } from "~/components/Notification";

import styles from "~/styles/Dashboard.module.css";
import moment from "moment";
import dayjs from "dayjs";

const { Title } = Typography;

Expand All @@ -24,7 +24,7 @@ function Dashboard() {
const { data: badges, isLoading: isLoadingBadges } = useBadges();

const nextEvent = () => {
const cur = moment();
const cur = dayjs();

const sorted_events = events
.filter((e: any) => cur.diff(e.start_time) < 0)
Expand Down
4 changes: 2 additions & 2 deletions apps/app/pages/lecture/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as api from "bokkenjs";
import { useAuth } from "@coderdojobraga/ui";
import { withAuth } from "~/components/Auth";
import AppLayout from "~/layouts/AppLayout";
import moment from "moment";
import dayjs from "dayjs";
import { EUser } from "bokkenjs";
import { notifyError, notifyInfo } from "~/components/Notification";

Expand Down Expand Up @@ -115,7 +115,7 @@ function Lectures() {
<Col>
<Text>
{!lecture.event ||
moment(new Date(lecture.event.start_time)).format("DD/MM/YYYY")}
dayjs(new Date(lecture.event.start_time)).format("DD/MM/YYYY")}
</Text>
</Col>
</Row>
Expand Down
4 changes: 2 additions & 2 deletions apps/app/pages/lectures/[role]/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CalendarOutlined, EditOutlined } from "@ant-design/icons";
import { withAuth } from "~/components/Auth";
import AppLayout from "~/layouts/AppLayout";
import * as api from "bokkenjs";
import moment from "moment";
import dayjs from "dayjs";
import { EUser } from "bokkenjs";
import { notifyError } from "~/components/Notification";

Expand Down Expand Up @@ -94,7 +94,7 @@ function Lectures() {
</Col>
<Col>
<Text>
{moment(new Date(lecture.event.start_time)).format(
{dayjs(new Date(lecture.event.start_time)).format(
"DD/MM/YYYY"
)}
</Text>
Expand Down
6 changes: 3 additions & 3 deletions apps/app/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Upload,
notification,
} from "antd";
import moment from "moment";
import dayjs from "dayjs";
import {
MinusCircleOutlined,
PlusOutlined,
Expand Down Expand Up @@ -291,8 +291,8 @@ function Settings() {
<DatePicker
showToday={false}
defaultValue={
(user?.birthday && moment(user.birthday, "YYYY-MM-DD")) ||
moment()
(user?.birthday && dayjs(user.birthday, "YYYY-MM-DD")) ||
dayjs()
}
/>
</Form.Item>
Expand Down
1 change: 1 addition & 0 deletions apps/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"antd": "^4.23.1",
"gray-matter": "^4.0.3",
"lodash-es": "^4.17.21",
"moment": "^2.29.4",
"next": "^12.3.4",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
10 changes: 4 additions & 6 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "npm run less:build && npm run next:dev",
"build": "npm run less:build && npm run next:build",
"dev": "npm run next:dev",
"build": "npm run next:build",
"start": "next start",
"lint": "npm run lint:fix",
"lint:fix": "next lint --fix",
"lint:check": "next lint",
"next": "next",
"next:build": "next build",
"next:dev": "next dev",
"less:build": "lessc --js styles/antd.less styles/antd.css"
"next:dev": "next dev"
},
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@coderdojobraga/ui": "*",
"@heroicons/react": "^2.0.8",
"@netlify/plugin-nextjs": "^4.29.2",
"antd": "^4.23.1",
"antd": "^5.0.0",
"next": "^12.3.4",
"react": "17.0.2",
"react-dom": "17.0.2"
Expand All @@ -31,7 +30,6 @@
"autoprefixer": "^10.4.8",
"eslint": "^8.23.0",
"eslint-config-coderdojobraga": "*",
"less": "^4.1.3",
"next-transpile-modules": "9.0.0",
"postcss": "^8.4.16",
"tailwind-config-coderdojobraga": "*",
Expand Down
4 changes: 0 additions & 4 deletions apps/web/styles/antd.less

This file was deleted.

Loading

0 comments on commit c03a199

Please sign in to comment.