Skip to content

Commit

Permalink
Merge pull request #84 from paziresh24/workhours-fragment
Browse files Browse the repository at this point in the history
feat: add duration to workhours fragment and add error toast for remo…
  • Loading branch information
AmirhBeigi authored Apr 27, 2024
2 parents 2226968 + 54973de commit f82608c
Show file tree
Hide file tree
Showing 9 changed files with 1,459 additions and 749 deletions.
20 changes: 19 additions & 1 deletion .plasmic/plasmic/opium/PlasmicDaysOfWeek.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const PlasmicDaysOfWeek__VariantProps = new Array();

export const PlasmicDaysOfWeek__ArgProps = new Array(
"selectedDay",
"selectTrigger"
"selectTrigger",
"cancelTrigger"
);

const $$ = {};
Expand Down Expand Up @@ -372,6 +373,23 @@ function PlasmicDaysOfWeek__RenderFunc(props) {
"updateSelectAllIsChecked"
];
}
$steps["updateSelectAllIsChecked2"] = true
? (() => {
const actionArgs = { eventRef: $props["cancelTrigger"] };
return (({ eventRef, args }) => {
return eventRef?.(...(args ?? []));
})?.apply(null, [actionArgs]);
})()
: undefined;
if (
$steps["updateSelectAllIsChecked2"] != null &&
typeof $steps["updateSelectAllIsChecked2"] === "object" &&
typeof $steps["updateSelectAllIsChecked2"].then === "function"
) {
$steps["updateSelectAllIsChecked2"] = await $steps[
"updateSelectAllIsChecked2"
];
}
}}
/>
</Stack__>
Expand Down
278 changes: 230 additions & 48 deletions .plasmic/plasmic/opium/PlasmicWorkhours.jsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/drapp/public/pwa-versions/latest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "3.175.0",
"name": "3.180.0",
"changeLog": "",
"tags": []
}
3 changes: 3 additions & 0 deletions apps/drapp/src/components/profile/expertises/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export const Expertises = props => {
});
}
props.setExpertise(visitesList);
},
onError: error => {
toast.error(error.response.data.message);
}
}
);
Expand Down
85 changes: 44 additions & 41 deletions apps/drapp/src/pages/drApp/setting/workHours/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const WorkHours = () => {
const getWorkHoursRequest = useGetWorkHours({ center_id: doctorInfo.center.id });
const removeWorkHours = useWorkHoursStore(state => state.removeWorkHours);
const duration = useWorkHoursStore(state => state.duration);
const [previousDuration, setPreviousDuration] = useState(duration);
const setDuration = useWorkHoursStore(state => state.setDuration);
const [activationModal, setActivationModal] = useState(false);
const completedActivationNotice = useFeatureValue(
Expand All @@ -51,16 +52,15 @@ const WorkHours = () => {
const useFragment = useFeatureIsOn('show-fragment-workhour-page');

useEffect(() => {
if (!useFragment) {
getWorkHoursRequest.remove();
getWorkHoursRequest.refetch();
}
getWorkHoursRequest.remove();
getWorkHoursRequest.refetch();
}, [doctorInfo.center]);

useEffect(() => {
if (getWorkHoursRequest.isSuccess) {
setWorkHours(getWorkHoursRequest.data.data.workhours);
setDuration(getWorkHoursRequest.data.data.duration);
setPreviousDuration(getWorkHoursRequest.data.data.duration);
}
}, [getWorkHoursRequest.status]);

Expand Down Expand Up @@ -101,9 +101,12 @@ const WorkHours = () => {
handleSubmit({ workHours: workHourClone, duration });
};

const handleSetDuration = (duration: number) => {
setDuration(duration);
handleSubmit({ workHours, duration });
const handleSetDuration = (prevDuration: number, newDuration: number) => {
setPreviousDuration(prevDuration);
setDuration(newDuration);
handleSubmit({ workHours, duration: newDuration }).catch(() => {
setDuration(prevDuration);
});
};

const handleSubmit = async ({
Expand Down Expand Up @@ -132,34 +135,20 @@ const WorkHours = () => {
error: error.response?.data
}
});
return Promise.reject(error);
}
}
};

if (useFragment) {
return (
<Container
maxWidth="sm"
className="pt-4 bg-white rounded-md md:p-5 md:mt-8 md:shadow-md"
>
<Fragment
name="HoursDaysOfWeek"
props={{
centerId: doctorInfo.center.id,
userCenterId: doctorInfo.center.user_center_id
}}
/>
</Container>
);
}

return (
<Container maxWidth="sm" className="pt-4 bg-white rounded-md md:p-5 md:mt-8 md:shadow-md">
<Stack className="pb-32 space-y-5 md:pb-0">
<SelectTime
items={durationList}
value={duration}
onChange={handleSetDuration}
onChange={newDuration => {
handleSetDuration(duration, newDuration);
}}
label={
getCenterType(doctorInfo.center) === 'consult'
? 'مدت زمان‌ ایده‌آل شما برای ارائه یک ویزیت جامع و پیوسته به یک بیمار چقدر است؟'
Expand All @@ -175,22 +164,36 @@ const WorkHours = () => {
پاسخگویی به سوالات احتمالی بیمار در دسترس باشید.
</Alert>
)}
<SelectDay selectedDays={days} onChange={setDays} />
<SelectHours defaultHours={hours} onChange={setHours} />
<Button
loading={isLoading}
onClick={handleAdd}
variant="contained"
className="self-end"
>
افزودن
</Button>
<Divider />
<Result
isLoading={getWorkHoursRequest.isLoading}
values={workHours}
removeAction={handleRemoveWorkHours}
/>
{useFragment && (
<Fragment
key={!isLoading ? duration : previousDuration}
name="HoursDaysOfWeek"
props={{
centerId: doctorInfo.center.id,
userCenterId: doctorInfo.center.user_center_id
}}
/>
)}
{!useFragment && (
<>
<SelectDay selectedDays={days} onChange={setDays} />
<SelectHours defaultHours={hours} onChange={setHours} />
<Button
loading={isLoading}
onClick={handleAdd}
variant="contained"
className="self-end"
>
افزودن
</Button>
<Divider />
<Result
isLoading={getWorkHoursRequest.isLoading}
values={workHours}
removeAction={handleRemoveWorkHours}
/>
</>
)}
{queryString.parse(window.location.search)['activation-path'] && (
<FixedWrapBottom className="border-t border-solid !bottom-0 border-[#e8ecf0]">
<Button
Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions plasmic.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
"componentImportPath": "@plasmicpkgs/plasmic-basic-components"
}
],
"customFunctions": [],
"jsBundleThemes": []
"customFunctions": []
},
{
"projectId": "oBJtsp5RgVpcN6KCrDTuQT",
Expand Down Expand Up @@ -218,8 +217,7 @@
"componentImportPath": "@plasmicapp/react-web/lib/data-sources"
}
],
"customFunctions": [],
"jsBundleThemes": []
"customFunctions": []
},
{
"projectId": "sqPBLwEBBKHA2WDuGb17eV",
Expand Down Expand Up @@ -309,8 +307,7 @@
"componentImportPath": "@plasmicpkgs/radix-ui"
}
],
"customFunctions": [],
"jsBundleThemes": []
"customFunctions": []
},
{
"projectId": "YUiM7yqBWAqsh8KSnrdj7",
Expand Down Expand Up @@ -338,8 +335,7 @@
"componentImportPath": "@plasmicpkgs/plasmic-query"
}
],
"customFunctions": [],
"jsBundleThemes": []
"customFunctions": []
},
{
"projectId": "h9Dbk9ygddw7UVEq1NNhKi",
Expand Down Expand Up @@ -481,8 +477,7 @@
"componentImportPath": "@plasmicapp/react-web/lib/data-sources"
}
],
"customFunctions": [],
"jsBundleThemes": []
"customFunctions": []
},
{
"projectId": "rqmTJ9WSF4RQaQFCvo2iUX",
Expand Down
12 changes: 6 additions & 6 deletions plasmic.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
},
{
"projectId": "sqPBLwEBBKHA2WDuGb17eV",
"version": "0.9.0",
"version": "0.10.0",
"dependencies": {},
"lang": "js",
"fileLocks": [
Expand Down Expand Up @@ -195,7 +195,7 @@
"projectId": "h9Dbk9ygddw7UVEq1NNhKi",
"version": "5.6.1",
"dependencies": {
"sqPBLwEBBKHA2WDuGb17eV": "0.9.0",
"sqPBLwEBBKHA2WDuGb17eV": "0.10.0",
"oBJtsp5RgVpcN6KCrDTuQT": "1.3.0",
"caTPwKxj5ZrD9LQ7DMdK4Z": "3.34.0"
},
Expand Down Expand Up @@ -448,12 +448,12 @@
{
"type": "renderModule",
"assetId": "2yLCE-L6JXEZ",
"checksum": "532683c72ee6fbf1c7532025bf020ef9"
"checksum": "4526c98bd859631eca7b568e90041b94"
},
{
"type": "cssRules",
"assetId": "2yLCE-L6JXEZ",
"checksum": "532683c72ee6fbf1c7532025bf020ef9"
"checksum": "4526c98bd859631eca7b568e90041b94"
},
{
"type": "renderModule",
Expand Down Expand Up @@ -508,12 +508,12 @@
{
"type": "renderModule",
"assetId": "oTc6QTbblo0F",
"checksum": "80fb281133c0ba819e3d34cf0de76535"
"checksum": "3ca7ac1fa9da26c21fbd4b4a6ebddf88"
},
{
"type": "cssRules",
"assetId": "oTc6QTbblo0F",
"checksum": "80fb281133c0ba819e3d34cf0de76535"
"checksum": "3ca7ac1fa9da26c21fbd4b4a6ebddf88"
},
{
"type": "renderModule",
Expand Down
Loading

0 comments on commit f82608c

Please sign in to comment.