Skip to content

Commit

Permalink
Merge pull request #1512 from themeum/course-bundle
Browse files Browse the repository at this point in the history
Updated `TutorShared` imports
  • Loading branch information
b-l-i-n-d authored Jan 9, 2025
2 parents b113462 + d15000c commit 1760b51
Show file tree
Hide file tree
Showing 101 changed files with 818 additions and 1,059 deletions.
66 changes: 35 additions & 31 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
{
"phpcbf.standard": "WordPress",
"phpcbf.enable": true,
"phpcbf.executablePath": "phpcbf",
"phpcbf.documentFormattingProvider": true,
"phpcbf.onsave": false,
"phpcbf.debug": false,
"yet-phpunit.xmlConfigFilepath": "${workspaceRoot}/wp-content/plugins/tutor/phpunit.xml.dist",
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.tslint": "always",
"source.organizeImports": "explicit"
},
"prettier.enable": true,
"eslint.enable": true,
"eslint.workingDirectories": [
"./wp-content/plugins/tutor"
],
}
"phpcbf.standard": "WordPress",
"phpcbf.enable": true,
"phpcbf.executablePath": "phpcbf",
"phpcbf.documentFormattingProvider": true,
"phpcbf.onsave": false,
"phpcbf.debug": false,
"yet-phpunit.xmlConfigFilepath": "${workspaceRoot}/wp-content/plugins/tutor/phpunit.xml.dist",
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.tslint": "always",
"source.organizeImports": "explicit"
},
"prettier.enable": true,
"eslint.enable": true,
"eslint.workingDirectories": ["./wp-content/plugins/tutor"]
}
5 changes: 5 additions & 0 deletions assets/react/v3/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ declare module '*.jpeg';
declare module '*.jpg';

declare global {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const wp: any;
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
wp: any;
ajaxurl: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tinymce: any;
_tutorobject: {
ajaxurl: string;
Expand All @@ -28,7 +31,9 @@ declare global {
enable_lesson_classic_editor: string;
tutor_frontend_dashboard_url: string;
backend_course_list_url: string;
backend_bundle_list_url: string;
frontend_course_list_url: string;
frontend_bundle_list_url: string;
wp_date_format: string;
wp_rest_nonce: string;
is_admin: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, BoxSubtitle, BoxTitle } from '@TutorShared/atoms/Box';
import CouponSelectItemModal from '@CouponComponents/modals/CourseListModal';
import { Box, BoxTitle } from '@TutorShared/atoms/Box';
import Button from '@TutorShared/atoms/Button';
import SVGIcon from '@TutorShared/atoms/SVGIcon';
import FormInputWithContent from '@TutorShared/components/fields/FormInputWithContent';
Expand All @@ -7,19 +8,18 @@ import { useModal } from '@TutorShared/components/modals/Modal';
import { tutorConfig } from '@TutorShared/config/config';
import { borderRadius, colorTokens, spacing } from '@TutorShared/config/styles';
import Show from '@TutorShared/controls/Show';
import CouponSelectItemModal from '@CouponComponents/modals/CourseListModal';

import { typography } from '@TutorShared/config/typography';
import type { Coupon } from '@CouponServices/coupon';
import { isAddonEnabled } from '@CourseBuilderUtils/utils';
import coursePlaceholder from '@SharedImages/course-placeholder.png';
import { Addons } from '@TutorShared/config/constants';
import { typography } from '@TutorShared/config/typography';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { isAddonEnabled } from '@TutorShared/utils/util';
import { requiredRule } from '@TutorShared/utils/validation';
import { css } from '@emotion/react';
import { __, sprintf } from '@wordpress/i18n';
import type { ReactNode } from 'react';
import { Controller, useFormContext } from 'react-hook-form';
import { Addons } from '@TutorShared/config/constants';

const isTutorProActive = !!tutorConfig.tutor_pro_url;
const displayBundle = isTutorProActive && isAddonEnabled(Addons.COURSE_BUNDLE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { typography } from '@/v3/shared/config/typography';
import SVGIcon from '@TutorShared/atoms/SVGIcon';
import { colorTokens, spacing } from '@TutorShared/config/styles';
import { typography } from '@TutorShared/config/typography';
import { css } from '@emotion/react';
import { __ } from '@wordpress/i18n';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import SVGIcon from '@TutorShared/atoms/SVGIcon';
import Tooltip from '@TutorShared/atoms/Tooltip';
import Tabs from '@TutorShared/molecules/Tabs';

import CertificateCard from '@CourseBuilderComponents/additional/CertificateCard';
import type { CourseDetailsResponse, CourseFormData } from '@CourseBuilderServices/course';
import { getCourseId } from '@CourseBuilderUtils/utils';
import { tutorConfig } from '@TutorShared/config/config';
import { Addons, CURRENT_VIEWPORT } from '@TutorShared/config/constants';
import { borderRadius, Breakpoint, colorTokens, spacing } from '@TutorShared/config/styles';
import { typography } from '@TutorShared/config/typography';
import For from '@TutorShared/controls/For';
import Show from '@TutorShared/controls/Show';
import CertificateCard from '@CourseBuilderComponents/additional/CertificateCard';
import type { CourseDetailsResponse, CourseFormData } from '@CourseBuilderServices/course';
import { getCourseId, isAddonEnabled } from '@CourseBuilderUtils/utils';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { isAddonEnabled } from '@TutorShared/utils/util';

import notFound2x from '@SharedImages/not-found-2x.webp';
import notFound from '@SharedImages/not-found.webp';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { typography } from '@TutorShared/config/typography';
import For from '@TutorShared/controls/For';
import Show from '@TutorShared/controls/Show';

import type { CourseDetailsResponse, GoogleMeet, MeetingType, ZoomMeeting } from '@CourseBuilderServices/course';
import { getCourseId } from '@CourseBuilderUtils/utils';
import config, { tutorConfig } from '@TutorShared/config/config';
import { Addons, CURRENT_VIEWPORT } from '@TutorShared/config/constants';
import type { CourseDetailsResponse, GoogleMeet, MeetingType, ZoomMeeting } from '@CourseBuilderServices/course';
import { getCourseId, isAddonEnabled } from '@CourseBuilderUtils/utils';
import { AnimationType } from '@TutorShared/hooks/useAnimation';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { noop } from '@TutorShared/utils/util';
import { isAddonEnabled, noop } from '@TutorShared/utils/util';

import GoogleMeetMeetingCard from './meeting/GoogleMeetCard';
import GoogleMeetForm from './meeting/GoogleMeetForm';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import { typography } from '@TutorShared/config/typography';
import { useFormWithGlobalError } from '@TutorShared/hooks/useFormWithGlobalError';
import { useIsScrolling } from '@TutorShared/hooks/useIsScrolling';

import Show from '@TutorShared/controls/Show';
import {
type GoogleMeet,
type GoogleMeetMeetingFormData,
useSaveGoogleMeetMutation,
} from '@CourseBuilderServices/course';
import { type ID, useGoogleMeetDetailsQuery } from '@CourseBuilderServices/curriculum';
import { useGoogleMeetDetailsQuery } from '@CourseBuilderServices/curriculum';
import { getCourseId } from '@CourseBuilderUtils/utils';
import Show from '@TutorShared/controls/Show';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { isDefined } from '@TutorShared/utils/types';
import { type ID, isDefined } from '@TutorShared/utils/types';
import { invalidDateRule, invalidTimeRule } from '@TutorShared/utils/validation';

interface GoogleMeetFormProps {
Expand Down Expand Up @@ -109,7 +109,6 @@ const GoogleMeetForm = ({ onCancel, data, topicId, meetingId }: GoogleMeetFormPr
}
};

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
if (isDefined(currentMeeting)) {
meetingForm.reset({
Expand Down Expand Up @@ -139,6 +138,7 @@ const GoogleMeetForm = ({ onCancel, data, topicId, meetingId }: GoogleMeetFormPr
return () => {
clearTimeout(timeoutId);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentMeeting]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import { borderRadius, colorTokens, fontSize, shadow, spacing, zIndex } from '@T
import { typography } from '@TutorShared/config/typography';
import { useFormWithGlobalError } from '@TutorShared/hooks/useFormWithGlobalError';

import { type ZoomMeeting, type ZoomMeetingFormData, useSaveZoomMeetingMutation } from '@CourseBuilderServices/course';
import { useZoomMeetingDetailsQuery } from '@CourseBuilderServices/curriculum';
import { getCourseId } from '@CourseBuilderUtils/utils';
import FormSelectInput from '@TutorShared/components/fields/FormSelectInput';
import { tutorConfig } from '@TutorShared/config/config';
import { DateFormats } from '@TutorShared/config/constants';
import Show from '@TutorShared/controls/Show';
import { type ZoomMeeting, type ZoomMeetingFormData, useSaveZoomMeetingMutation } from '@CourseBuilderServices/course';
import { type ID, useZoomMeetingDetailsQuery } from '@CourseBuilderServices/curriculum';
import { getCourseId } from '@CourseBuilderUtils/utils';
import { useIsScrolling } from '@TutorShared/hooks/useIsScrolling';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { isDefined } from '@TutorShared/utils/types';
import { type ID, isDefined } from '@TutorShared/utils/types';
import { invalidTimeRule } from '@TutorShared/utils/validation';

interface ZoomMeetingFormProps {
Expand Down Expand Up @@ -100,7 +100,6 @@ const ZoomMeetingForm = ({ onCancel, data, meetingHost, topicId, meetingId }: Zo
}
};

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
if (isDefined(currentMeeting)) {
meetingForm.reset({
Expand All @@ -124,6 +123,7 @@ const ZoomMeetingForm = ({ onCancel, data, meetingHost, topicId, meetingId }: Zo
return () => {
clearTimeout(timeoutId);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentMeeting]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import MagicButton from '@TutorShared/atoms/MagicButton';
import SVGIcon from '@TutorShared/atoms/SVGIcon';
import { useToast } from '@TutorShared/atoms/Toast';

import { useSaveAIGeneratedCourseContentMutation } from '@TutorShared/services/magic-ai';
import { getCourseId } from '@CourseBuilderUtils/utils';
import FormTextareaInput from '@TutorShared/components/fields/FormTextareaInput';
import { Addons, isRTL } from '@TutorShared/config/constants';
import { Breakpoint, borderRadius, colorTokens, spacing, zIndex } from '@TutorShared/config/styles';
import { typography } from '@TutorShared/config/typography';
import For from '@TutorShared/controls/For';
import Show from '@TutorShared/controls/Show';
import { useSaveAIGeneratedCourseContentMutation } from '@CourseBuilderServices/magic-ai';
import { getCourseId, isAddonEnabled } from '@CourseBuilderUtils/utils';
import { useFormWithGlobalError } from '@TutorShared/hooks/useFormWithGlobalError';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { getObjectKeys, getObjectValues } from '@TutorShared/utils/util';
import { getObjectKeys, getObjectValues, isAddonEnabled } from '@TutorShared/utils/util';

import { useGenerateCourseContent } from '../../hooks/useGenerateCourseContent';
import ContentAccordion from './ContentAccordion';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useContext, useMemo, useRef, useState, type ReactNode } from 'react';

import type { QuizContent } from '@CourseBuilderServices/magic-ai';
import type { QuizContent } from '@TutorShared/services/magic-ai';
import { isDefined } from '@TutorShared/utils/types';
import { noop } from '@TutorShared/utils/util';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import SVGIcon from '@TutorShared/atoms/SVGIcon';

import FormRadioGroup from '@TutorShared/components/fields/FormRadioGroup';

import type { CourseFormData } from '@CourseBuilderServices/course';
import config, { tutorConfig } from '@TutorShared/config/config';
import { Addons } from '@TutorShared/config/constants';
import { Breakpoint, colorTokens, spacing } from '@TutorShared/config/styles';
import { typography } from '@TutorShared/config/typography';
import type { CourseFormData } from '@CourseBuilderServices/course';
import { isAddonEnabled } from '@CourseBuilderUtils/utils';
import { isAddonEnabled } from '@TutorShared/utils/util';

const ContentDripSettings = () => {
const form = useFormContext<CourseFormData>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ import {} from 'react-router-dom';

import SVGIcon from '@TutorShared/atoms/SVGIcon';

import ScheduleOptions from '@CourseBuilderComponents/course-basic/ScheduleOptions';
import FormCategoriesInput from '@TutorShared/components/fields/FormCategoriesInput';
import FormImageInput from '@TutorShared/components/fields/FormImageInput';
import FormInput from '@TutorShared/components/fields/FormInput';
import FormSelectInput from '@TutorShared/components/fields/FormSelectInput';
import FormSelectUser, { type UserOption } from '@TutorShared/components/fields/FormSelectUser';
import FormTagsInput from '@TutorShared/components/fields/FormTagsInput';
import FormVideoInput from '@TutorShared/components/fields/FormVideoInput';
import ScheduleOptions from '@CourseBuilderComponents/course-basic/ScheduleOptions';

import type { CourseDetailsResponse, CourseFormData } from '@CourseBuilderServices/course';
import { getCourseId } from '@CourseBuilderUtils/utils';
import { tutorConfig } from '@TutorShared/config/config';
import { Addons, DateFormats, TutorRoles } from '@TutorShared/config/constants';
import { Breakpoint, colorTokens, headerHeight, spacing } from '@TutorShared/config/styles';
import { typography } from '@TutorShared/config/typography';
import Show from '@TutorShared/controls/Show';
import type { CourseDetailsResponse, CourseFormData } from '@CourseBuilderServices/course';
import { getCourseId, isAddonEnabled } from '@CourseBuilderUtils/utils';
import { useInstructorListQuery, useUserListQuery } from '@TutorShared/services/users';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { isAddonEnabled } from '@TutorShared/utils/util';

import CoursePricing from './CoursePricing';

const courseId = getCourseId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ import { useLocation, useNavigate } from 'react-router-dom';
import FormInputWithContent from '@TutorShared/components/fields/FormInputWithContent';
import FormRadioGroup from '@TutorShared/components/fields/FormRadioGroup';
import FormSelectInput from '@TutorShared/components/fields/FormSelectInput';
import SubscriptionPreview from '@CourseBuilderComponents/subscription/SubscriptionPreview';

import { tutorConfig } from '@TutorShared/config/config';
import { Addons } from '@TutorShared/config/constants';
import { spacing } from '@TutorShared/config/styles';
import Show from '@TutorShared/controls/Show';
import {
type CourseDetailsResponse,
type CourseFormData,
type WcProduct,
useGetWcProductsQuery,
useWcProductDetailsQuery,
} from '@CourseBuilderServices/course';
import { getCourseId, isAddonEnabled } from '@CourseBuilderUtils/utils';
import { getCourseId } from '@CourseBuilderUtils/utils';
import SubscriptionPreview from '@TutorShared/components/subscription/SubscriptionPreview';
import { tutorConfig } from '@TutorShared/config/config';
import { Addons } from '@TutorShared/config/constants';
import { spacing } from '@TutorShared/config/styles';
import Show from '@TutorShared/controls/Show';
import { styleUtils } from '@TutorShared/utils/style-utils';
import { isDefined } from '@TutorShared/utils/types';
import { isAddonEnabled } from '@TutorShared/utils/util';
import { requiredRule } from '@TutorShared/utils/validation';

const courseId = getCourseId();
Expand Down Expand Up @@ -104,7 +105,6 @@ const CoursePricing = () => {
return uniqueProducts;
};

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
if (wcProductsQuery.isSuccess && wcProductsQuery.data) {
const { course_pricing } = courseDetails || {};
Expand All @@ -120,9 +120,9 @@ const CoursePricing = () => {
});
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [wcProductsQuery.data]);

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
if (!tutorConfig.edd_products || !tutorConfig.edd_products.length) {
return;
Expand All @@ -140,9 +140,9 @@ const CoursePricing = () => {
shouldValidate: true,
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tutorConfig.edd_products]);

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
if (tutorConfig.settings?.monetize_by !== 'wc') {
return;
Expand Down Expand Up @@ -174,6 +174,7 @@ const CoursePricing = () => {
if (!isCourseSalePriceDirty) {
form.setValue('course_sale_price', '0');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [wcProductDetailsQuery.data]);

return (
Expand Down
Loading

0 comments on commit 1760b51

Please sign in to comment.